www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1459] New: ICE on attempt to set value of non-lvalue return struct

reply d-bugmail puremagic.com writes:
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


-- 
Aug 30 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1459






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 19 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1459


Don <clugdbug yahoo.com.au> changed:

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





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
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1459






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: -------
May 27 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1459


Walter Bright <bugzilla digitalmars.com> changed:

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





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: -------
Jul 09 2009