https://issues.dlang.org/show_bug.cgi?id=12958
Issue ID: 12958
Summary: core.checkedint.mulu is broken
Product: D
Version: D2
Hardware: x86
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: druntime
Assignee: [email protected]
Reporter: [email protected]
The current [1] version of core.checkedint.mulu is broken. For example, 2^(n/2)
* 2^(n/2), where n is the bit width of the integer result, will produce r = 0,
but no overflow will be detected.
For the ulong case, I think that short of using floating point or trial
division for verification, the best implementation might be to split up the
numbers into 32 bit parts and perform the combining step manually (and checking
for overflow there).
[1]
https://github.com/D-Programming-Language/druntime/blob/12a0deafe2b1a573b489bce1719971fae0b219ff/src/core/checkedint.d#L445
--