Bug 15450 – ICE during CTFE of legit function

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-12-15T23:00:00Z
Last change time
2016-03-19T20:21:36Z
Keywords
ice, pull
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2015-12-15T23:00:22Z
Repro below fails with: dmd: interpret.c:1034: Expression* interpret(FuncDeclaration*, InterState*, Expressions*, Expression*): Assertion `!e || (e->op != TOKcontinue && e->op != TOKbreak)' failed. ==================== struct BigO { struct Atom { int id; double exp; double logExp; } private Atom[][] terms; int opCmp(const BigO rhs) const { int result = 0; bigone: foreach (ref l; terms) { foreach (ref r; rhs.terms) { if (l == r) continue bigone; if (smaller(l, r)) { if (result == 1) return 0; if (result == 0) result = -1; continue bigone; } if (smaller(r, l)) { if (result == -1) return 0; if (result == 0) result = 1; continue bigone; } } // Not comparable return 0; } return result; } private static bool smaller(const(Atom)[] lhs, const(Atom)[] rhs) { return 0; } } static immutable linear = BigO([ [ BigO.Atom(0, 1, 0) ] ]); static assert(linear >= linear);
Comment #1 by andrei — 2015-12-15T23:01:37Z
Shorter repro. It's the labeled continue that's the problem: struct BigO { struct Atom { int id; double exp; double logExp; } private Atom[][] terms; int opCmp(const BigO rhs) const { int result = 0; bigone: foreach (ref l; terms) { foreach (ref r; rhs.terms) { continue bigone; } } return result; } } static immutable linear = BigO([ [ BigO.Atom(0, 1, 0) ] ]); static assert(linear >= linear);
Comment #2 by ag0aep6g — 2015-12-15T23:21:51Z
2.069.2 gives "Error: cannot interpret <continue> at compile time", which is at least not an ICE. git head (6cd7173) gives "[email protected](1008): Assertion failure", making this a diagnostic regression. Further reduced test case: ---- static assert({ bigone: foreach (l; [0]) continue bigone; return true; }()); ----
Comment #3 by andrei — 2015-12-15T23:53:38Z
Nice, thanks. Hmmm, I was running v2.068.2. So should we qualify this as silently fixed?
Comment #4 by andrei — 2015-12-15T23:54:53Z
Oh wait, the HEAD doesn't work either (albeit with a different diagnostic). So this bug stands. Thanks!
Comment #5 by k.hara.pg — 2015-12-16T14:11:28Z
(In reply to ag0aep6g from comment #2) > 2.069.2 gives "Error: cannot interpret <continue> at compile time", which is > at least not an ICE. > > git head (6cd7173) gives "[email protected](1008): > Assertion failure", making this a diagnostic regression. From 2.069.0, released dmd binary is compiled with -release, so all of internal asserts won't hit. Note that, ICE also happens with 2.068, like: Assertion failure: '!e || (e->op != TOKcontinue && e->op != TOKbreak)' on line 1034 in file 'interpret.c' abnormal program termination Therefore, this is not a regression from 2.069.
Comment #6 by k.hara.pg — 2015-12-16T14:11:46Z
Comment #7 by github-bugzilla — 2016-01-08T18:27:20Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7d477b5be6e174a529fbeffceb61593624201897 Reboot #5312: fix Issue 15450 - ICE during CTFE of legit function https://github.com/D-Programming-Language/dmd/commit/a540e39b75fc02b91fe448f52e242db5765723e3 Merge pull request #5336 from WalterBright/reboot5313 Reboot #5312: fix Issue 15450 - ICE during CTFE of legit function
Comment #8 by github-bugzilla — 2016-03-19T20:21:36Z