Bug 1459 – ICE(cgcs.c) on attempt to set value of non-lvalue return struct

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-08-30T22:02:00Z
Last change time
2014-02-16T15:26:03Z
Keywords
ice-on-invalid-code, patch
Assigned to
bugzilla
Creator
wbaxter

Comments

Comment #0 by wbaxter — 2007-08-30T22:02:55Z
struct Payload { int i,j; } //alias int Payload; // ok with this -- get "not an lvalue" class Ouch { Payload property(int idx) { return props[idx]; } void set(int x, Payload t) { property(x) = t; } Payload[] props; } // Internal error: ..\ztc\cgcs.c 217
Comment #1 by clugdbug — 2009-05-19T00:30:19Z
Marginally simpler test case ----- struct Payload { int x; } Payload y; Payload property() { return y; } void main() { property() = y; }
Comment #2 by clugdbug — 2009-05-27T01:08:42Z
Root cause: Structs should not be considered lvalues if they are function return values. PATCH expression.c, CallExp::toLvalue() + Type *tb = e1->type->toBasetype(); + if (type->toBasetype()->ty == Tstruct && tb->ty != Tfunction) - if (type->toBasetype()->ty == Tstruct) return this;
Comment #3 by clugdbug — 2009-05-27T01:39:19Z
That patch was incomplete, we also need to test for delegates. // Revised patch. + Type *tb = e1->type->toBasetype(); + if (type->toBasetype()->ty == Tstruct && tb->ty != Tfunction && tb->ty!=Tdelegate) - if (type->toBasetype()->ty == Tstruct) return this; // Test case 2 struct Payload { int x; } Payload y; void main() { Payload delegate(int) bar; bar(1) = y; }
Comment #4 by bugzilla — 2009-07-09T02:54:21Z
Fixed dmd 1.046