|Posted by Zach the Mystic||PermalinkReply|
Summary: auto ref returns a reference its own stack
--- Comment #0 from Zach the Mystic <firstname.lastname@example.org> 2013-02-19 10:54:14 PST ---
I'm conservatively marking this 'normal' although it actually seems 'major' to
Monarch Dodra has said that this code compiles:
auto ref foo(T)(auto ref T t)
int* p = &foo(tuple(1, 2));
Our concern is that p could only be pointing to the vaporized stack at this point. tuple(1,2) is a rvalue struct type, which means that function 'foo' should be interpreting its parameter 't' as a value, not a reference. t therefore is a derived from a value type, which should not be returnable by ref.
Value parameters should not be returnable by 'ref'. That is an obvious stack-breaking maneuver. I don't know exactly where the problem is at this point, or if there are multiple unsafe operations here:
1) auto ref parameter assumed to be a reference when spec says its a value
2) index of a tuple not understood to be derived from a value parameter (i.e.
3) 'auto ref' completely defeating its purpose by returning a reference to a
4) some syntactical ambiguity with '&foo(tuple(1,2))' which I'm not aware of
5) taking the address of something returned as a value
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------