Bug 10927 – Power of complex number causes an internal error

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-30T06:32:00Z
Last change time
2013-11-12T13:47:18Z
Keywords
CTFE, ice, pull
Assigned to
nobody
Creator
ttanjo

Comments

Comment #0 by ttanjo — 2013-08-30T06:32:21Z
The following code causes an internal error in dmd v2.064-devel-2d0de85 on Linux 64bit. --- void main() { auto a = (1+2i)^^3; } --- Output: $ rdmd error.d 1.00000 cdouble 0x1bfe8e0 cdouble 0x1bfe8e0 ty = 29, tym = 19 Internal error: e2ir.c 1424
Comment #1 by hsteoh — 2013-08-30T15:34:55Z
Built-in complex numbers are deprecated; instead, use std.complex: ---- import std.complex; import std.stdio; void main() { writeln(complex(1,2)^^3); // prints -11-2i } ---- I'll leave this bug open, though, since an ICE is a problem even if it's caused by deprecated features.
Comment #2 by yebblies — 2013-11-12T07:57:22Z
constfold's Pow is completely broken for complex numbers - it assumes everything not integral is floating point. It calculates the power on the real part only, then produces a RealExp with type Tcomplex64, hence the ice. This also fails: static assert( (1+2i) ^^ 3 == -11 - 2i ); testx.d(3): Error: static assert (1.00000 == (-11+-2i)) is false https://github.com/D-Programming-Language/dmd/pull/2751
Comment #3 by github-bugzilla — 2013-11-12T13:47:11Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/74229511ec91a4d929bcc23234237e1f9db69df6 Fix Issue 10927 - Power of complex number causes an internal error https://github.com/D-Programming-Language/dmd/commit/b48595b7020ee7a91fd620257d16dd976edb1610 Merge pull request #2751 from yebblies/issue10927 Issue 10927 - Power of complex number causes an internal error