Skip to content

tests: make issue_848 overflow test portable to 32-bit usize#1881

Open
c-tonneslan wants to merge 1 commit into
rust-bakery:mainfrom
c-tonneslan:fix/issue-848-test-portable-overflow
Open

tests: make issue_848 overflow test portable to 32-bit usize#1881
c-tonneslan wants to merge 1 commit into
rust-bakery:mainfrom
c-tonneslan:fix/issue-848-test-portable-overflow

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #1879.

The regression test for #848 hardcodes 0x2000000000000000_usize, which is fine on 64-bit but won't fit in a 32-bit usize and breaks the build on i386 (Debian carries a downstream patch for exactly this).

The test only needs the take size to be big enough to overflow sz.checked_mul(8) inside bits::bytes, i.e. anything strictly greater than usize::MAX / 8. Switched to usize::MAX / 8 + 1 so it picks the minimum overflowing value on every platform without a cfg(target_arch = "x86") split.

Ran cargo test --test issues issue_848 locally on aarch64-apple-darwin, still passes.

The regression test for rust-bakery#848 hardcoded 0x2000000000000000_usize, which
is fine on 64-bit but won't fit in a 32-bit usize and fails to compile
on i386. Debian ships a downstream patch for this (see rust-bakery#1879).

The test just needs a take size large enough to overflow
sz.checked_mul(8) inside bits::bytes, i.e. anything bigger than
usize::MAX / 8. Switching to usize::MAX / 8 + 1 picks the minimum
overflowing value on every platform without a cfg split.

Closes rust-bakery#1879

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
@c-tonneslan c-tonneslan requested a review from Geal as a code owner May 16, 2026 13:21
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.

[i386] Numeric literal 0x2000000000000000_usize out of range in tests

1 participant