[Issue 21325] New: Wrong code with -release -inline -O
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Oct 18 08:36:07 UTC 2020
    
    
  
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 at puremagic.com
          Reporter: thomas.bockman at 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
    }
}
////////////////////////////////////////////////
--
    
    
More information about the Digitalmars-d-bugs
mailing list