Skip to content

BigInt hashing broken #58711

Closed
Closed
@jmkuhn

Description

@jmkuhn
julia> versioninfo()
Julia Version 1.13.0-DEV.732
Commit a970e16c3f (2025-06-11 16:51 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin24.5.0)
  CPU: 12 × Apple M2 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.2 (ORCJIT, apple-m2)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)

julia> hash(BigInt(10)^30)
ERROR: InexactError: convert(UInt64, -8)
Stacktrace:
 [1] throw_inexacterror(func::Symbol, to::Type, val::Int64)
   @ Core ./boot.jl:863
 [2] check_sign_bit
   @ ./boot.jl:869 [inlined]
 [3] toUInt64
   @ ./boot.jl:980 [inlined]
 [4] UInt64
   @ ./boot.jl:1010 [inlined]
 [5] hash_bytes(ptr::Ptr{UInt8}, n::Int64, seed::UInt64, secret::Tuple{UInt64, UInt64, UInt64})
   @ Base ./hashing.jl:252
 [6] hash(x::BigInt, h::UInt64)
   @ Base.GMP ./gmp.jl:900
 [7] hash(data::BigInt)
   @ Base ./hashing.jl:33
 [8] top-level scope
   @ REPL[2]:1

ref #58440
@adienes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions