Repository navigation
Comparisons with constants as values in signed_compare.c, both outcomes in enums.c - #96
Merged
Merged
Conversation
…es in enums.c signed_compare.c tested the comparisons as values only between two variables, and against constants only as branches: the case the value form got wrong was not in it. It now takes all four relations as values against constants, of any 16-bit value and of a difference of bytes (no overflow possible), and fails without the previous commit's fix. That showed the bug was wider: x < 0 and x >= 0 as values gave 1 for every 16-bit x. enums.c ran each comparison on one input, and its true result was the one the broken code always gave. Each comparison now also runs on an input that makes it false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skerkewitz
approved these changes
Nov 29, 2026
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.
What
Closes the gap in the tests that let the miscompile fixed in #94 through. This commit was meant for #94 but reached GitHub after #94 was merged.
exec/signed_compare.c, added with Signed comparisons by one subtraction, and the absolute difference as one instruction #89, took signed comparisons as values only between two variables, and against constants only as branches. The case The value of a signed comparison with a constant reads C again, not N #94 fixed, a comparison against a constant stored as a value, wasn't in it. It now takes all four relations as values against constants: of any 16-bit value, and of a difference of two bytes, where the value ranges rule out an overflow.exec/enums.chad the broken case,dir - 1 < 0, but on one input whose right answer (1) was what the broken code always gave. Each comparison now also runs on an input that makes it false.Verified
signed_compare.cdiffers in exactly the new values (134 of 748), and in its 16-bit part only inx < 0andx >= 0: those gave 1 for every 16-bitx, since a comparison with 0 never overflows../gradlew buildondevelopwith this commit: 1,272 tests, 0 failed, 13 skipped.What follows
backend-output.txt. The compiler is unchanged.StyleGuideTest, the game, documents, book: unchanged.🤖 Generated with Claude Code