Bug 6732 – ICE: __traits(compiles) fails on valid expression

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-09-26T09:14:00Z
Last change time
2012-01-06T07:35:49Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-09-26T09:14:17Z
template isDouble(T) { enum bool isDouble = __traits(hasMember, T, "x") || is(T == double); } void test(T)(T rhs) if (is(T == int)) { } void test(T)(T rhs) if (isDouble!T) { } void main() { static assert(__traits(compiles, test(4.5))); // fail test(4.5); // fine } If you comment out the static assert you'll see that the test() call compiles. Oddly enough if you swap the order of the calls like so: void main() { test(4.5); static assert(__traits(compiles, test(4.5))); } Then it works again.
Comment #1 by andrej.mitrovich — 2012-01-04T06:55:23Z
The following has now turned into an ICE (is a crash equivalent to an ICE?) in 2.057: template isDouble(T) { enum bool isDouble = __traits(hasMember, T, "x"); } void test(T)(T rhs) if (isDouble!T) { } void main() { test(4.5); } --------------------------- dmd.exe - Application Error --------------------------- The instruction at "0x00489e61" referenced memory at "0x00000000". The memory could not be "read".
Comment #2 by k.hara.pg — 2012-01-06T07:35:49Z
ICE problem on comment#1 was fixed in bug 7108. And the original problem on comment#0 was fixed in bug 7123. Finally this issue was completely fixed in 2.058head.