Skip to content

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

Description

@ermakov0

On the i386 (32-bit x86) architecture, the size of usize in Rust is 4 bytes (32 bits)

https://github.com/rust-bakery/nom/blob/main/tests/issues.rs#L145

I proposed a patch for Debian to make the test pass. But I'm not sure it's correct.

From: Ermakov Alexander <ermakovav@altgtu.ru>
Date: Mar, 04 2026 09:49:33 +0700
Subject: Fix out of range in tests for i386
Forwarded: no

--- rust-nom-7-7.1.3.orig/tests/issues.rs
+++ rust-nom-7-7.1.3/tests/issues.rs
@@ -139,7 +139,10 @@ mod issue_647 {
 fn issue_848_overflow_incomplete_bits_to_bytes() {
   fn take(i: &[u8]) -> IResult<&[u8], &[u8]> {
     use nom::bytes::streaming::take;
-    take(0x2000000000000000_usize)(i)
+    #[cfg(not(target_arch = "x86"))]
+    { take(0x2000000000000000_usize)(i) }
+    #[cfg(target_arch = "x86")]
+    { take(0x20000000_usize)(i) }
   }
   fn parser(i: &[u8]) -> IResult<&[u8], &[u8]> {
     use nom::bits::{bits, bytes};

https://sources.debian.org/src/rust-nom-7/7.1.3-3/debian/patches/fix-tests-for-i386.patch

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions