digitalmars.D.bugs - [Issue 8538] New: array variadic apparently doesn't get copied in closure
- d-bugmail puremagic.com (42/42) Aug 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8538
http://d.puremagic.com/issues/show_bug.cgi?id=8538 Summary: array variadic apparently doesn't get copied in closure Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: minor Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: destructionator gmail.com --- Comment #0 from Adam D. Ruppe <destructionator gmail.com> 2012-08-11 12:23:47 PDT --- === void delegate() test(Object[] objs...) { return { foreach(obj; objs) assert(obj); }; } void delegate() foo() { return test(new Object, new Object); } void main() { auto ok = test(new Object, new Object); ok(); // no problem auto it = foo(); // but if we build the array elsewhere it(); // this triggers a failure } === My guess is the arguments are on the enclosing stack, so the ok() call is fine, because the test call is still there. But, the foo call leaves that [new Object, new Object] on the stack, which is now potentially invalid. Other local variables are copied in this situation for a closure, but it looks like the variadic arg case was overlooked. Marked as minor because it is very easy to work around and this combination of features is super rare anyway. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 11 2012