Skip to content

Commit

Permalink
fix Issue 17087 - [REG2.072] Wrong generated with cfloat and creal wh…
Browse files Browse the repository at this point in the history
…en casting from int
  • Loading branch information
WalterBright authored and MartinNowak committed Jan 17, 2017
1 parent 661be50 commit 7cf3c76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/e2ir.d
Expand Up @@ -4411,7 +4411,7 @@ elem *toElem(Expression e, IRState *irs)
case X(Tfloat64,Tcomplex32):
case X(Tfloat64,Tcomplex64):
case X(Tfloat64,Tcomplex80):
e = el_bin(OPadd,TYcfloat,el_long(TYidouble,0),e);
e = el_bin(OPadd,TYcdouble,el_long(TYidouble,0),e);
fty = Tcomplex64;
goto Lagain;

Expand Down
11 changes: 11 additions & 0 deletions test/runnable/complex.d
Expand Up @@ -404,6 +404,16 @@ void test15()
assert(bar15r(1.0L, 2.0Li) == 1.0L + 2.0Li);
}

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

cfloat toComplex(int x) { return cast(cfloat)x; }

void test17087()
{
assert (toComplex(1) == 1.0);
}

/***************************************/

int main(char[][] args)
Expand Down Expand Up @@ -432,6 +442,7 @@ int main(char[][] args)
test7806();
test7976();
test15();
test17087();

printf("Success!\n");
return 0;
Expand Down

0 comments on commit 7cf3c76

Please sign in to comment.