[Issue 574] New: DMD uses D calling convention for returning complex floats from functions with C calling convention

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 19 14:44:33 PST 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 at digitalmars.com
        ReportedBy: thomas-dloop at 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)


-- 




More information about the Digitalmars-d-bugs mailing list