test: fix address-dependent pointer tests and macOS toolchain noise - #242
Merged
Conversation
test_char_sized_ptr_math_{incr,decr} truncate two addresses four bytes
apart to unsigned char and subtract them, expecting a difference of 4.
That only holds when the subtraction does not borrow out of the low
byte, so the tests fail whenever the stack happens to place `a` at an
address whose low byte is 0x00 (decr) or 0xfc (incr) -- roughly a 1 in
64 chance, since `a` is 4-byte aligned. This is what failed the Windows
job on #240:
FAILED test_consistent_return_value_c[test_char_sized_ptr_math_decr--O1]
- assert 4294967046 == 6
Truncating the difference back to unsigned char makes the result 4 for
every address while still exercising the same char-sized pointer math at
-O0. At -O1 and above the optimizer now folds main() to `return 6`,
which is itself a proof that the result no longer depends on the address.
Separately, check_no_output() treats any stderr as a failure, including
diagnostics that describe the toolchain rather than the code under test.
When the macOS SDK and the Homebrew bottles are built for different OS
versions, every compile emits
clang: warning: overriding deployment version from '16.0' to '26.0'
which failed all 540 tests on #237 despite an exit code of 0. Filter
that class of environmental warning out before deciding whether the
process misbehaved; real diagnostics are unaffected.
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
test_char_sized_ptr_math_{incr,decr} truncate two addresses four bytes apart to unsigned char and subtract them, expecting a difference of 4. That only holds when the subtraction does not borrow out of the low byte, so the tests fail whenever the stack happens to place
aat an address whose low byte is 0x00 (decr) or 0xfc (incr) -- roughly a 1 in 64 chance, sinceais 4-byte aligned. This is what failed the Windows job on #240:FAILED test_consistent_return_value_c[test_char_sized_ptr_math_decr--O1]
- assert 4294967046 == 6
Truncating the difference back to unsigned char makes the result 4 for every address while still exercising the same char-sized pointer math at -O0. At -O1 and above the optimizer now folds main() to
return 6, which is itself a proof that the result no longer depends on the address.Separately, check_no_output() treats any stderr as a failure, including diagnostics that describe the toolchain rather than the code under test. When the macOS SDK and the Homebrew bottles are built for different OS versions, every compile emits
clang: warning: overriding deployment version from '16.0' to '26.0'
which failed all 540 tests on #237 despite an exit code of 0. Filter that class of environmental warning out before deciding whether the process misbehaved; real diagnostics are unaffected.
Assisted-by: Claude Opus 5 (1M context) noreply@anthropic.com