www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17173] New: Incorrect return value for function accepting and

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

--
Feb 10