www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5178] New: StructLiteral should not be lvalue

reply d-bugmail puremagic.com writes:
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: -------
Nov 06 2010
next sibling parent d-bugmail puremagic.com writes:
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: -------
Mar 31 2011
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 30 2012