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 ***