Skip to content

Decimal u64 literals >= 2^63 pass check but lose bit 63 at runtime #68

Closed

Description

@ehartford

Current behavior

Suffixed decimal u64 literals at or above 2^63 pass with check, but the runtime value behaves as if bit 63 was cleared.

Minimal repro 1:

fn main:
    let x: u64 = 9223372036854775808u64
    assert((x >> 63) == 1u64)
with check /tmp/with_u64_high_literal.w   # ok
with run /tmp/with_u64_high_literal.w     # panics: assertion failed

Minimal repro 2:

fn main:
    let mask: u64 = 18446744073709551615u64
    assert((mask >> 63) == 1u64)
with check /tmp/with_u64_max_literal.w    # ok
with run /tmp/with_u64_max_literal.w      # panics: assertion failed

Why this matters

This breaks any code that relies on exact high-bit u64 values, including bit masks, exact word assembly, and literal-driven constant paths.

In Crux this surfaced while reconstructing 64-bit constants from exact bit patterns: a value intended to be 0xf0f0f0f0f0f0f0f0 behaved like 0x70f0f0f0f0f0f0f0, which drops the top bit and changes popcount from 32 to 31.

Expected behavior

Both programs should run successfully. u64 literals that fit in range must preserve their exact runtime value, including bit 63.

Spec references

docs/with-specification.md says:

  • Primitive unsigned integer types include u64 at lines 688-689.
  • Integer literal suffixes include u64 at lines 724-727.
  • Suffixed literals are explicit and part of the literal token at lines 739-743.
  • A suffixed literal must fit in its declared type at lines 775-776.

These literals do fit in u64, so they should evaluate to their exact declared value at runtime.

Activity

  1. added a commit that references this issue on Jun 8, 2026
    eb67123
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