Comment #0 by matti.niemenmaa+dbugzilla — 2006-11-18T09:55:04Z
The following code is directly from the spec:
int test(int i ...)
{
return i;
}
void main()
{
test(3);
}
The spec claims that "[a]n implementation may construct the object or array instance on the stack. Therefore, it is an error to refer to that instance after the variadic function has returned". This would seem to allow doing this for parameters which aren't object or array instances. Indeed, the spec gives the above code as an example of how "[f]or other types, the argument is built with itself".
I'd say DMD is in error here. I've yet to realise how "int test(int i ...)" is any better or different from "int test(int i)", though.
Comment #1 by matti.niemenmaa+dbugzilla — 2006-11-18T09:55:53Z
Of course I forget to explain the bug itself. Currently, DMD errors out with:
asdf.d(5): Error: escaping reference to variadic parameter i
Comment #2 by matti.niemenmaa+dbugzilla — 2006-12-03T03:39:58Z