Repository navigation
Report an out-of-range prefix length in C tests - #384
Merged
jserv merged 1 commit intoOct 21, 2026
Merged
Conversation
jserv
reviewed
Oct 20, 2026
jserv
requested changes
Oct 20, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Avoid commit messages such as Update web/compiler-explorer.js, as Git already tracks which files have changed.
ColtenOuO
requested changes
Oct 20, 2026
ColtenOuO
left a comment
Collaborator
There was a problem hiding this comment.
Please squash your commits.
ericodingTWICEaWEAK
force-pushed
the
fix-382-c-prefix-length
branch
from
October 20, 2026 18:29
92c82f0 to
2fc7f4b
Compare
Contributor
Author
|
Done. I've squashed my commits into a single commit. Thanks! |
ColtenOuO
reviewed
Oct 20, 2026
ColtenOuO
left a comment
Collaborator
There was a problem hiding this comment.
Don't leave this in:
Update web/compiler-explorer.js
Co-authored-by: xxx
The C harness clamped a returned prefix length that was negative or larger than the input array to zero. A solution that always returned -1 therefore passed every case whose expected result is empty, and an oversized length showed up as an empty array instead of an error. Print the same diagnostic the C++, Java, JavaScript and Python harnesses already use, and keep the bounds check ahead of the array print so the harness never reads past the buffer. The cost is a longer generated C statement in the harness template.
ericodingTWICEaWEAK
force-pushed
the
fix-382-c-prefix-length
branch
from
October 20, 2026 18:38
2fc7f4b to
df7ea23
Compare
Contributor
Author
|
Done. I've removed them. Thanks! |
ColtenOuO
approved these changes
Oct 20, 2026
ColtenOuO
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, Let's wait for the CI.
Contributor
|
Thank @ericodingTWICEaWEAK for contributing! |
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.
The C harness for in-place prefix exercises such as
remove-elementandremove-duplicates-from-sorted-arrayclamped a negative or oversized returned length to 0 and printed[], so a solution that always returns-1passed the cases whose expected result is empty and an oversized length produced no explanation.The harness now reports
Return value must be an integer length for the kept prefix.as anerrorresult when the length is outside0..numsSize, the same diagnostic and result shape as the C++, Java, JavaScript and Python harnesses, and the bounds check runs beforejson_int_arrayso the buffer is never read past its size.A unit test in
tests/browser/compiler-explorer.test.jsasserts that the generated C harness contains the bounds guard and the error result, next to the existing Java assertion forremove-element.Closes #382