Fix testHelperFunctions int64 overflow (test bug) + strengthen coverage#487
Open
leginee wants to merge 1 commit into
Open
Fix testHelperFunctions int64 overflow (test bug) + strengthen coverage#487leginee wants to merge 1 commit into
leginee wants to merge 1 commit into
Conversation
DamjanJovanovic
approved these changes
Jun 21, 2026
test_t_abs64 used bare 2147483648 literals whose width is implementation-defined: 32-bit on ILP32/LLP64 (win32), 64-bit on LP64. "2147483648 << 1" and "* 2" therefore overflowed to 0 in 32-bit arithmetic before being widened to sal_Int64, so the n != 0 assertions failed. Latent on 64-bit Linux, surfaced on the win32 test migration. - test1/test2: force 64-bit operands (sal_Int64(...)), matching the already-correct test1_1 idiom; test0 (the deliberate 32-bit narrowing overflow demo) is left untouched. - t_abs64 printf: %ld -> SAL_PRIdINT64 (wrong wherever long is 32-bit). - Replace weak "> 0" / "!= 0" checks with exact-value assertions written as independent constants, so a regression to 32-bit arithmetic is actually caught. - Add test_abs64_range: exercises 0, +/-1, +/-SAL_MAX_INT64 exactly and documents the SAL_MIN_INT64 two's-complement boundary. Test-only, C++98, platform-neutral; no shipping source touched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
715affe to
85082b9
Compare
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.
This PR is the second out of 3 fixes from test migration. They failed on the 32bit system because they did not have a 64 bit guard and behaved incorrect in the windows 32 bit build. Added guards to ensure correct behaviour.
This is based on AI generation better have multiple eyes review the code.
commit message for conveniance
test_t_abs64 used bare 2147483648 literals whose width is implementation-defined: 32-bit on ILP32/LLP64 (win32), 64-bit on LP64. "2147483648 << 1" and "* 2" therefore overflowed to 0 in 32-bit arithmetic before being widened to sal_Int64, so the n != 0 assertions failed. Latent on 64-bit Linux, surfaced on the win32 test migration.
Test-only, C++98, platform-neutral; no shipping source touched.