www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20363] New: optimization with union, >> and ulong leads to

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 puremagic.com
          Reporter: bugzilla 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.

--
Nov 06 2019