[Dlang-internal] Complex numbers

Walter Bright via Dlang-internal dlang-internal at puremagic.com
Tue Oct 18 19:28:58 PDT 2016


On 10/16/2016 1:05 PM, Ilya Yaroshenko wrote:
> The site says they are deprecated. In the same time it is real pain to use
> core.stdc.complex with std.complex.

I've noticed that gcc generates significantly different code for these two 
functions:

   #include <complex.h>
   struct S { double re, im; };
   struct S foo(struct S* ps) { return *ps; }
   double complex bar(double complex *ps) { return *ps; }

The S versions are much worse. This is not good.

The ABIs are, sadly, different as well. The following should behave equivalently 
as far as ABI goes:

   double complex

   struct complex { double re, im; }

   double[2]

but alas, they do not.


More information about the Dlang-internal mailing list