digitalmars.D.bugs - [Issue 21325] New: Wrong code with -release -inline -O
- d-bugmail puremagic.com (33/33) Oct 18 2020 https://issues.dlang.org/show_bug.cgi?id=21325
https://issues.dlang.org/show_bug.cgi?id=21325 Issue ID: 21325 Summary: Wrong code with -release -inline -O Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: thomas.bockman gmail.com The program below should return 0. On Linux x86_64 it works properly with LDC or GDC, and even with DMD in debug mode. But, it fails and returns 1 with DMD -release -inline -O. (This was reduced from a multi-thousand line program.) //////////////////////////////////////////////// module app; real f(const real x) pure safe nothrow nogc { return (x != 0.0L)? x : real.nan; } int main() safe { ulong x = 0uL; while(true) { const y = f(x); // should set y to real.nan if(y == y) return 1; // bad if(++x) return 0; // good } } //////////////////////////////////////////////// --
Oct 18 2020