digitalmars.D.bugs - [Issue 16223] New: BigUint: undefined shift for small instantiation
- via Digitalmars-d-bugs (25/25) Jun 30 2016 https://issues.dlang.org/show_bug.cgi?id=16223
https://issues.dlang.org/show_bug.cgi?id=16223 Issue ID: 16223 Summary: BigUint: undefined shift for small instantiation type Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: jbc.engelen gmail.com 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). --
Jun 30 2016