Bug 10883 – [ICE] Internal error: ../ztc/cod4.c 358 when compiling with -inline
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-24T09:33:00Z
Last change time
2015-06-09T01:31:16Z
Keywords
ice, pull
Assigned to
yebblies
Creator
doob
Comments
Comment #0 by doob — 2013-08-24T09:33:47Z
I get "Internal error: ../ztc/cod4.c" when compiling the following code with -inline on Mac OS X:
U getValueOfField (T, U, string field) (T t)
{
foreach (i, dummy ; typeof(T.tupleof))
return t.tupleof[i];
assert(0, "Should not happen");
}
class Foo
{
auto bar = "foo";
}
void main ()
{
auto a = getValueOfField!(Foo, string, "bar")(new Foo);
}
If I do any of the following the error disappears:
* Remove the assignment to "a"
* Remove the foreach loop
* Add a return statement after the assert
* Compile without -inline
Comment #1 by yebblies — 2013-11-20T07:32:47Z
The inliner is stupid, and keeps inlining after the unconditional return inside the foreach (because it's inside a compound statement, inside an unrolled statement, etc)
This eventually results in var = ("foo", assert(0)) which triggers the assert in the backend.
https://github.com/D-Programming-Language/dmd/pull/2837
Comment #2 by github-bugzilla — 2013-11-25T04:12:37Z