[Issue 20363] New: optimization with union, >> and ulong leads to wrong result
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Nov  6 16:43:44 UTC 2019
    
    
  
https://issues.dlang.org/show_bug.cgi?id=20363
          Issue ID: 20363
           Summary: optimization with union, >> and ulong leads to wrong
                    result
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at d-ecke.de
auto test(double val)
{
    union A
    {
        double a;
        ulong b;
    }
    A fb;
    fb.a = val;
    auto sgn = ((fb.b >> 63) & 1) ? "-" : "+";
    import std.stdio;
    writeln(sgn);
}
void main()
{
    test(-double.nan);
}
When running this with "rdmd -O" I get "+" not the expected "-". Without the -O
flag it works.
--
    
    
More information about the Digitalmars-d-bugs
mailing list