Bug 560 – Cannot escape reference to variadic parameter

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-18T09:55:00Z
Last change time
2014-02-15T13:19:43Z
Keywords
rejects-valid, spec
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla
Blocks
511

Comments

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
Fixed in DMD 0.176.