www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23778] New: Code generator fails to handle __c_complex_real

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

          Issue ID: 23778
           Summary: Code generator fails to handle __c_complex_real
                    properly for Windows
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Test code:
----
enum __c_long_double : double;
alias __c_long_double c_long_double;

struct _Complex {
    c_long_double re;
    c_long_double im;
}

version (all) { // fails
    enum __c_complex_real   : _Complex;
    alias c_complex_real = __c_complex_real;
}
else // works
    enum c_complex_real   : _Complex;

c_complex_real toNative2(real re, real im) {
    return c_complex_real(re, im);
}

void main() {
    c_complex_real n = toNative2(123, 456);
    assert(123 == n.re && 456 == n.im);
}
---------
The trouble is that __c_complex_real is treated specially in the compiler, and
in totym() it is always replaced with TYcldouble. On Windows where long doubles
are actually doubles, it should be TYldouble.

--
Mar 14 2023