www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21515] New: extern(C) and extern(C++) returns creal in wrong

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

          Issue ID: 21515
           Summary: extern(C) and extern(C++) returns creal in wrong order
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

This program fails.
---
extern "C" _Complex long double ctwol() { return 1+0Li; }

extern(C) creal ctwol();  // Because extern(C++) ICE's

void main()
{
    auto a = ctwol();
    assert(a.re == 2 && a.im == 0);
}
---

DMD generates:
    callq  d <_Dmain+0xd>
    fstpt  -0x10(%rbp)
    fstpt  -0x20(%rbp)

When it should instead do:
    callq  d <_Dmain+0xd>
    fstpt  -0x20(%rbp)
    fstpt  -0x10(%rbp)

--
Dec 29 2020