[Issue 17173] New: Incorrect return value for function accepting and returning cdouble

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Feb 10 06:56:41 PST 2017


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

          Issue ID: 17173
           Summary: Incorrect return value for function accepting and
                    returning cdouble
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: meapineapple at gmail.com

This code behaves correctly when compiling with DMD v2.072.0 on Win7. It
behaves incorrectly with the same DMD version on OSX.

    import std.stdio;

    auto fn(in cdouble value){
        writeln(value.re + 0i); // Prints 64+0i
        return value.re + 0i;
    }

    unittest{
        writeln(fn(64 + 0i)); // Prints 64+64i, should print 64+0i
    }

It behaves correctly if:

If writeln is removed from fn (In the case where I encountered this bug, there
was other essential code but no writeln, I don't think this is related to
writeln specifically)

If an empty out contract is added to fn

--


More information about the Digitalmars-d-bugs mailing list