November 19, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=574

           Summary: DMD uses D calling convention for returning complex
                    floats from functions with C calling convention
           Product: D
           Version: 0.174
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: thomas-dloop@kuehne.cn


DMD uses D calling convention for returning complex floats from functions with C calling convention.

complex_d.d :
#
# extern(C){
#     cfloat test_cfloat(cfloat);
#     cdouble test_cdouble(cdouble);
#     creal test_creal(creal);
# }
#
# import std.stdio;
# void main(){
#     writefln("cfloat:  %s\t(5+2i)", test_cfloat(2 + 1i));
#     writefln("cdouble: %s\t(4+6i)", test_cdouble(1 + 2i));
#     writefln("creal:   %s\t(16+5i)", test_creal(3 + 1i));
# }
#

complex_c.c :
#
# float _Complex test_cfloat(float _Complex a){
#     return a * 2 + 1;
# }
#
# double _Complex test_cdouble(double _Complex a){
#     return a * 3 + 1;
# }
#
# long double _Complex test_creal(long double _Complex a){
#     return a * 5 + 1;
# }
#

gcc -m32 -c complex_c.c && dmd complex_c.o complex_d.d -ofcomplex && ./complex

output:
> cfloat:  nan+nani       (5+2i)
> Segmentation fault

expected output:
> cfloat:  5+2i   (5+2i)
> cdouble: 4+6i   (4+6i)
> creal:   16+5i  (16+5i)


-- 

December 08, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=574


bugzilla@digitalmars.com changed:

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




------- Comment #1 from bugzilla@digitalmars.com  2006-12-08 02:56 -------
Fixed DMD 0.176


--