Thread overview
[Issue 1459] New: ICE on attempt to set value of non-lvalue return struct
Aug 31, 2007
d-bugmail
[Issue 1459] ICE(cgcs.c) on attempt to set value of non-lvalue return struct
May 19, 2009
Don
May 27, 2009
Don
May 27, 2009
Don
Jul 09, 2009
Walter Bright
August 31, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1459

           Summary: ICE on attempt to set value of non-lvalue return struct
           Product: D
           Version: 1.020
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: wbaxter@gmail.com


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


-- 

May 19, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1459





--- Comment #1 from Don <clugdbug@yahoo.com.au>  2009-05-19 00:30:19 PDT ---
Marginally simpler test case
-----
struct Payload {
  int x;
}
Payload y;
Payload property() {
  return y;
}
void main() {
    property() = y;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1459


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch




--- Comment #2 from Don <clugdbug@yahoo.com.au>  2009-05-27 01:08:42 PDT ---
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;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1459





--- Comment #3 from Don <clugdbug@yahoo.com.au>  2009-05-27 01:39:19 PDT ---
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;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 09, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1459


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #4 from Walter Bright <bugzilla@digitalmars.com>  2009-07-09 02:54:21 PDT ---
Fixed dmd 1.046

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------