Bug 16223 – BigUint: undefined shift for small instantiation type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-06-30T15:42:53Z
Last change time
2019-12-04T09:04:44Z
Keywords
pull
Assigned to
No Owner
Creator
Johan Engelen

Comments

Comment #0 by jbc.engelen — 2016-06-30T15:42:53Z
Module std.internal.math.biguintcore contains the code: ``` static BigUint mulInt(T = ulong)(BigUint x, T y) pure nothrow { if (y==0 || x == 0) return BigUint(ZERO); uint hi = cast(uint)(y >>> 32); ``` The ">>> 32" is undefined for sizeof(T)*8 <= 32 (so for T = int, uint, char, ...). There should at least be a check that the function is not instantiated for types equal or smaller than 32 bits. No bug yet, because the only usage of mulInt is with T=ulong (bigint.d).
Comment #1 by dlang-bot — 2019-12-03T17:00:36Z
@berni44 created dlang/phobos pull request #7300 "Fix Issue 16223 - BigUint: undefined shift for small instantiation type" fixing this issue: - Fix Issue 16223 - BigUint: undefined shift for small instantiation type https://github.com/dlang/phobos/pull/7300
Comment #2 by dlang-bot — 2019-12-04T09:04:44Z
dlang/phobos pull request #7300 "Fix Issue 16223 - BigUint: undefined shift for small instantiation type" was merged into master: - 38c33ed793ec27120611eac792af2417e8beaeb6 by Bernhard Seckinger: Fix Issue 16223 - BigUint: undefined shift for small instantiation type https://github.com/dlang/phobos/pull/7300