Skip to content

Fix tests to use Bits::Signed for 128-bit extremes - #154

Merged
nikolaykosarev merged 1 commit into
masterfrom
nkosarev/tests-with-extremes
Jul 30, 2026
Merged

Fix tests to use Bits::Signed for 128-bit extremes#154
nikolaykosarev merged 1 commit into
masterfrom
nkosarev/tests-with-extremes

Conversation

@nikolaykosarev

@nikolaykosarev nikolaykosarev commented Jul 27, 2026

Copy link
Copy Markdown

Literal hex numbers are treated as bitvectors, and the tests
constructed the min 128-bit integer by negating an unsigned value:

let min_128 := -Std::Bits::Unsigned(0x8000_0000_0000_0000_0000_0000_0000_0000);

However, Bits::Unsigned(0x80...00) already gives -2**127 (the minimum).
Negating it produces 2**127 which overflows __int128 in the C23 backend:

min_128 = ((__int128)(- ((__int128)((unsigned __int128)((unsigned __int128)0x80000000000000000000000000000000uwb)))));

Use Bits::Signed and drop the negation. This avoids the overflow and expresses the intended values
better.

Literal hex numbers are treated as bitvectors, and the tests
constructed the min 128-bit integer by negating an unsigned value:

    let min_128 := -Std::Bits::Unsigned(0x8000_0000_0000_0000_0000_0000_0000_0000);

However, Bits::Unsigned(0x80...00) already gives -2**127 (the minimum).
Negating it produces 2**127 which overflows __int128 in the C23 backend:

    min_128 = ((__int128)(- ((__int128)((unsigned __int128)((unsigned __int128)0x80000000000000000000000000000000uwb)))));

Use Bits::Signed and drop the negation. This avoids the overflow and
expresses the intended values better.
@nikolaykosarev
nikolaykosarev force-pushed the nkosarev/tests-with-extremes branch from 9955671 to 04528b4 Compare July 27, 2026 13:38
@nikolaykosarev

Copy link
Copy Markdown
Author

Without this change, the tests fail (locally) for me. Unclear yet why they did not fail at PR testing at #148 ...

@nikolaykosarev
nikolaykosarev merged commit 7b13423 into master Jul 30, 2026
1 check passed
@nikolaykosarev
nikolaykosarev deleted the nkosarev/tests-with-extremes branch July 30, 2026 07:47
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