Skip to content

prod(::Vector{BigInt}) broken on 1.8 and master #46665

@thofma

Description

@thofma

It would be great if the following could be fixed for 1.8 (it is working fine on <= 1.7).

julia> prod(BigInt[0, 0])
ERROR: InexactError: check_top_bit(UInt64, -64)
Stacktrace:
  [1] throw_inexacterror(f::Symbol, #unused#::Type{UInt64}, val::Int64)
    @ Core ./boot.jl:614
  [2] check_top_bit
    @ ./boot.jl:628 [inlined]
  [3] toUInt64
    @ ./boot.jl:739 [inlined]
  [4] UInt64
    @ ./boot.jl:769 [inlined]
  [5] convert
    @ ./number.jl:7 [inlined]
  [6] cconvert
    @ ./essentials.jl:412 [inlined]
  [7] init2!
    @ ./gmp.jl:143 [inlined]
  [8] BigInt
    @ ./gmp.jl:56 [inlined]
  [9] prod(arr::Vector{BigInt})
    @ Base.GMP ./gmp.jl:673
 [10] top-level scope
    @ REPL[1]:1

The line

abs(x.size) * BITS_PER_LIMB - leading_zeros(unsafe_load(x.d))

looks wrong, in particular the unsafe_load(x.d).

CC: @rfourquet

Metadata

Metadata

Assignees

No one assigned

    Labels

    bignumsBigInt and BigFloatregressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions