Thread overview
[Issue 5178] New: StructLiteral should not be lvalue
Nov 06, 2010
Kenji Hara
Mar 31, 2011
Walter Bright
Jan 31, 2012
yebblies
November 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5178

           Summary: StructLiteral should not be lvalue
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2010-11-06 03:49:16 PDT ---
Created an attachment (id=802)
Patch for DMD svn r737

This code generates wrong code.

struct S{}
void swap(ref S a, ref S b){}
ref S get(){return S();}  //should be rejected
void main(){
    swap(get(), get());
}

In function swap, a and b access invalid local stack address.
I think StructLiteral should not be lvalue, but current dmd allows it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5178


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2011-03-31 15:24:09 PDT ---
I believe the patch is the wrong fix. It is valid for struct literals (and other temporaries) to be lvalues.

What is not valid is to return a reference to a stack variable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5178


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #2 from yebblies <yebblies@gmail.com> 2012-01-31 14:36:09 EST ---
*** This issue has been marked as a duplicate of issue 5889 ***

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