Bug 4465 – ICE(symbol.c): immutable type inference with ^^2

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2010-07-15T06:41:00Z
Last change time
2010-09-22T17:44:54Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2010-07-15T06:41:42Z
Test case: void f() { int g() { immutable z = 2^^2; // or const, doesn't matter return z; } } Error: Internal error: ../ztc/symbol.c 1041 The error message disappears if you - make g() return something other than z - make z mutable - assign z something other than a power expression
Comment #1 by bugzilla — 2010-07-15T08:40:25Z
Turns out this has nothing to do with the function being nested. This fails too, with the same error: int g() { immutable z = 2^^2; return z; }
Comment #2 by clugdbug — 2010-08-13T03:03:40Z
Reduced test case. Doesn't even need a return. It only happens for x^^2 and x^^3, and that's because those cases become comma expressions. Probably something is wrong in fromConstInitializer(). void bug4465() { const a = 2 ^^ 2; int b = a; }
Comment #3 by clugdbug — 2010-08-13T12:15:34Z
One option would be to change PowExp to stop using CommaExp, but I think that lowering involving comma expressions is such a useful internal feature that it's worth supporting. --------------- PATCH: optimize.c, fromConstInitializer(), line 142. e = expandVar(result, v); if (e) { + // If it is a comma expression involving a declaration, we mustn't + // perform a copy -- we'd get two declarations of the same variable. + // See bugzilla 4465. + if (e->op == TOKcomma && ((CommaExp *)e)->e1->op == TOKdeclaration) + e= e1; + else if (e->type != e1->type && e1->type && e1->type->ty != Tident) { // Type 'paint' operation e = e->copy();
Comment #4 by bugzilla — 2010-09-22T17:44:54Z