Skip to content

Fix testHelperFunctions int64 overflow (test bug) + strengthen coverage#487

Open
leginee wants to merge 1 commit into
trunkfrom
Fix-testHelperFunctions-int64-overflow-(test-bug)
Open

Fix testHelperFunctions int64 overflow (test bug) + strengthen coverage#487
leginee wants to merge 1 commit into
trunkfrom
Fix-testHelperFunctions-int64-overflow-(test-bug)

Conversation

@leginee

@leginee leginee commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

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.

  • 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.

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>
@leginee leginee force-pushed the Fix-testHelperFunctions-int64-overflow-(test-bug) branch from 715affe to 85082b9 Compare June 21, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants