Thread overview
[Issue 21515] extern(C) and extern(C++) returns creal in wrong order
Dec 29, 2020
Iain Buclaw
Dec 30, 2020
Dlang Bot
Jan 25, 2021
Dlang Bot
December 29, 2020
https://issues.dlang.org/show_bug.cgi?id=21515

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #1 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Iain Buclaw from comment #0)
> This program fails.
> ---
> extern "C" _Complex long double ctwol() { return 1+0Li; }
> 
Oops, that should be 2+0Li.  :-)

--
December 30, 2020
https://issues.dlang.org/show_bug.cgi?id=21515

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ibuclaw created dlang/dmd pull request #12073 "Attempt fixing Issue 21515
extern(C) and extern(C++) returns creal in wrong order" mentioning this issue:

- Attempt fixing Issue 21515

https://github.com/dlang/dmd/pull/12073

--
January 25, 2021
https://issues.dlang.org/show_bug.cgi?id=21515

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12073 "fix Issue 21515 extern(C) and extern(C++)
returns creal in wrong order" was merged into master:

- 7e445d61509f97de902528b9c68bd5d247563e14 by Iain Buclaw:
  fix Issue 21515 - extern(C) and extern(C++) returns creal in wrong order

  In loadComplex and complex_eq87, the real part of x87 complex numbers
  are pushed to the FPU register stack first (ST1), then the imaginary
  part (ST0).  However, on the I64 ABI, real part is instead returned in
  ST0 and the imaginary part in ST1. To handle this, FXCH is inserted
  before returning from, and after calling a complex long double function.

https://github.com/dlang/dmd/pull/12073

--