Bug 5178 – StructLiteral should not be lvalue

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-11-06T03:49:00Z
Last change time
2012-01-30T19:36:09Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
k.hara.pg

Attachments

IDFilenameSummaryContent-TypeSize
802fix.patchPatch for DMD svn r737text/plain862

Comments

Comment #0 by k.hara.pg — 2010-11-06T03:49:16Z
Created attachment 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.
Comment #1 by bugzilla — 2011-03-31T15:24:09Z
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.
Comment #2 by yebblies — 2012-01-30T19:36:09Z
*** This issue has been marked as a duplicate of issue 5889 ***