Bug 7091 – ICE in Statement::blockExit

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-12-10T11:51:00Z
Last change time
2012-04-28T02:58:17Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
hoganmeier

Comments

Comment #0 by hoganmeier — 2011-12-10T11:51:14Z
struct Matrix(T) { int opApply(scope int delegate(ref size_t, ref T) ) { } int opApply(scope int delegate(ref const(size_t), ref const(T)) ) { } Matrix!() opBinary() { foreach (i, ref val; this) mixin("result[i] = val " ~ op ~ " other[i];"); return result; } } void main() { auto m = Matrix!size_t; } $ dmd -c test2.d test2.d(7): Error: template instance Matrix!() Matrix!() does not match template declaration Matrix(T) test2.d(7): Error: Matrix!() is used as a type test2.d(4): Error: function test2.Matrix!(ulong).Matrix.opApply has no return statement, but is expected to return a value of type int test2.d(5): Error: function test2.Matrix!(ulong).Matrix.opApply has no return statement, but is expected to return a value of type int test2.d(8): Error: cannot uniquely infer foreach argument types test2.d(9): Error: undefined identifier result Statement::blockExit(0xcd15e0) mixin("result[i] = val " ~ op ~ " other[i];"); dmd: statement.c:144: virtual int Statement::blockExit(bool): Assertion `0' failed.
Comment #1 by hoganmeier — 2011-12-10T11:52:22Z
more valid case: struct Matrix(T) { @property T[] data() { return null; } int opApply(scope int delegate(ref size_t[], ref T) dg) { return 0; } int opApply(scope int delegate(ref const(size_t[]), ref const(T)) dg) const { return 0; } Matrix!(typeof(mixin("data[0] " ~ op ~ " data[0]"))) opBinary(string op)(Matrix other) { auto result = typeof(return)(); foreach (i, ref val; this) { mixin("result[i] = val " ~ op ~ " other[i];"); } return result; } } void main() { auto m = Matrix!size_t(); m = m * m; } $ dmd -c test2.d test2.d(11): Error: cannot uniquely infer foreach argument types Statement::blockExit(0x1c509c0) mixin("result[i] = val " ~ op ~ " other[i];"); dmd: statement.c:144: virtual int Statement::blockExit(bool): Assertion `0' failed.
Comment #2 by k.hara.pg — 2011-12-10T13:52:48Z
More simple test code: ---- void main() { int[] arr; foreach (x, i, v; arr) { mixin(""); } } output: ---- test.d(4): Error: cannot infer type for i test.d(4): Error: cannot infer type for v Statement::blockExit(002B6810) mixin(""); Assertion failure: '0' on line 144 in file 'statement.c' abnormal program termination
Comment #3 by k.hara.pg — 2011-12-10T14:40:37Z
This problem occurs only on invalid code. So it isn't 'ice-on-valid-code'. Patch: https://github.com/D-Programming-Language/dmd/pull/553
Comment #4 by hoganmeier — 2011-12-12T18:22:20Z
Comment #5 by lovelydear — 2012-04-28T02:58:17Z
No more ICE on 2.059 Win32