[Issue 5541] Disallow escaping of references to stack-allocated memory

2013-01-16 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5541


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution||WORKSFORME


--- Comment #3 from yebblies yebbl...@gmail.com 2013-01-17 12:36:55 EST ---
None of this compiles any more with 2.062 head

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


[Issue 5541] Disallow escaping of references to stack-allocated memory

2012-02-09 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5541


timon.g...@gmx.ch changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||timon.g...@gmx.ch
 Resolution|INVALID |


--- Comment #2 from timon.g...@gmx.ch 2012-02-09 15:21:53 PST ---
This is not about struct literals being lvalues, Walter states this is by
design anyway.
Furthermore, struct literals are certainly allocated on the stack and what
bearophile shows is not valid code.

struct Foo {
int x;
}
Foo* bar() {
return (Foo(1));
}
void qux(ref Foo f,int x){
writeln(f.x);
}
void main() {
Foo* x = bar();
qux(*bar(),2);
}

compiling and running for 32 bit prints garbage, and looking at the disassembly
shows that the literal is indeed allocated on the stack.

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


[Issue 5541] Disallow escaping of references to stack-allocated memory

2012-01-31 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5541


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||yebbl...@gmail.com
 Resolution||INVALID


--- Comment #1 from yebblies yebbl...@gmail.com 2012-02-01 15:25:08 EST ---
(In reply to comment #0)
 But this code compiles and runs with no errors with DMD 2.051. I think DMD has
 to statically disallow code like this too:
 
 
 struct Foo {
 int x;
 }
 Foo* bar() {
 return (Foo(1));
 }
 void main() {}

Believe it or not, this is valid code.  In D struct literals are currently
lvalues, and not allocated on the stack at all.  See issue 5889.

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