Bug 12498 – ICE: while(string) causes compiler to crash during CTFE
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-31T04:48:00Z
Last change time
2014-04-03T06:09:46Z
Keywords
ice, pull
Assigned to
nobody
Creator
olav
Comments
Comment #0 by olav — 2014-03-31T04:48:35Z
Example: http://dpaste.dzfl.pl/31b055067ef4
This fails because the while is being checked against a string. Replace "enum" with "string" in main, and it compiles and executes at runtime.
I also posted this to the forums, which contains the link to a longer example (after Dustmite, but before manual cleanups): http://forum.dlang.org/thread/[email protected]#post-qxaqnmoifiubktfuyjcw:40forum.dlang.org
It works on LDC 1.076 and DMD 2.x Git (cfb5842b49) (how old is that?), according to Dpaste, but not on DMD 2.065 (both Dpaste and my Ubuntu 64bit).
- Olav.
Comment #1 by andrej.mitrovich — 2014-03-31T05:17:04Z
Thanks for the reduced sample, but in the future please paste code samples inline (dpaste can sometimes go offline):
-----
string a()
{
string b;
while (b) { } // ICE
return "";
}
void main()
{
enum t = a();
string x = t;
}
-----
$ dmd test.d
-----
test.d(12): called from here: a()
test.d(12): called from here: a()
__error
DMD v2.066 DEBUG
[] error Internal error: e2ir.c 858
-----