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
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7c3629ab82f4c0ad4a61f7e657a587c9bb3e2ec7 Fix Issue 10883 - [ICE] Internal error: ../ztc/cod4.c 358 when compiling with -inline Catch unconditional returns inside other statements to avoid inlining asserts as expressions.