[Issue 20688] New: Wrong code when linking to C complex number functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 20 02:36:31 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20688
Issue ID: 20688
Summary: Wrong code when linking to C complex number functions
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P2
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
C program:
/////////////////// test.c ///////////////////
#include <stdio.h>
#include <complex.h>
int main()
{
double complex r = cpow(2 + 0*I, 2 + 0*I);
printf("%f+%fi\n", creal(r), cimag(r));
return 0;
}
//////////////////////////////////////////////
As expected, this prints 4.000000+0.000000i.
Equivalent D program:
////////////////// test.d /////////////////
import std.stdio;
import core.stdc.complex;
void main()
{
cdouble r = cpowf(2. + 0i, 2. + 0i);
printf("%f+%fi\n", creal(r), cimag(r));
}
///////////////////////////////////////////
This prints garbage (for me, randomly -0.000000+-0.000000i or nan+nani).
--
More information about the Digitalmars-d-bugs
mailing list