Repository navigation
Avoid overlapping borrows in repeated-character append - #580
Merged
nunoplopes merged 3 commits intoNov 2, 2026
Merged
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repeated-character string append now reads the target length before borrowing the receiver for resizing. This avoids a checked-borrow panic for strings whose data pointer is used, including calls that ignore the result.
sizeof.Runtime borrow checking and the unsafe-model rule are unchanged. This repairs the receiver's own length read; it does not change append's return-reference semantics or operand evaluation.
Testing
tests/unit/string_repeat_append.cpp checks size, receiver bytes and the trailing zero over a bounded grid of initial lengths, counts and byte values, with and without shrinking first. It includes empty strings, zero counts, embedded NULs and growth, plus unboxed-local, reference and pointer receivers. The scoped lit runner passes four tests with no failures or skips, comparing native C++ with both output models and checking their generated-source expectations. The existing string fixture checks the surrounding string rules.
Coverage is bounded; application frequency remains unmeasured.
4 recorded checks pass with this change.
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.