[Issue 13474] 32 bit DMD optimizer FP arithmetic bug

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Feb 9 04:40:18 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13474

--- Comment #14 from Илья Ярошенко <ilyayaroshenko at gmail.com> ---
(In reply to yebblies from comment #7)
> change(-1e100) calculates its result at real precision, then returns it in
> ST(0).  It is duplicated via the stack (truncating to double) but the full
> precision value is then added with (1e104) and due to the extra precision
> they no longer cancel exactly, instead resulting in
> -1.3987216024025249e+0087.
> 
> This value causes the later addition 10000 to be ignored, leading to the
> wrong result and the assertion failure.
> 
> So, is it invalid to return a double in ST0 without first truncating it to
> double precision?

I think so. Looks like LDC and GDC have truncation.

--


More information about the Digitalmars-d-bugs mailing list