[Issue 16223] New: BigUint: undefined shift for small instantiation type
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jun 30 08:42:53 PDT 2016
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 at puremagic.com
Reporter: jbc.engelen at 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).
--
More information about the Digitalmars-d-bugs
mailing list