Bug 12581 – [ICE](statement.c, line 713) with invalid assignment + alias this

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-15T08:35:00Z
Last change time
2014-04-15T18:17:40Z
Keywords
ice, pull
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2014-04-15T08:35:38Z
The root cause of the ICE is same with bug 12501 and bug 12574, but the fixing way is a bit different. struct S { int[3] a; alias a this; } struct T { S s; alias s this; } void main() { T x; x[] = (undef = 1); } --- assert statement.c(713) global.gaggedErrors || global.errors
Comment #1 by k.hara.pg — 2014-04-15T09:29:45Z
Comment #2 by github-bugzilla — 2014-04-15T18:17:39Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/de1a6e570e2b7a135d40ce0bebc312be90e2101a fix Issue 12581 - [ICE](statement.c, line 713) with invalid assignment + alias this Make AssignExp::semantic reentrant for `op_overload` call. ----- If an expression supports operator overloading, its `semantic` function should not store error expressions in itself until the point of `op_olverload` call (from [a] to [b]). Example: Expression *XXXExp::semantic(Scope sc) { // [a] ... e1 = e1->semantic(sc); // Bad: if semantic analysis returns ErrorExp, // it is stored in this->e1 immediately. if (e1->op == TOKerror) return e1; // [b] Expression *e = op_overload(sc); if (e) return e; ... } If `XXXExp::semantic` is called from the `trySemantic` call for `alias this` analysis (from `op_overload` function in `opover.c`), the stored ErrorExp would accidentally escape from the gagged period.