[Issue 13508] array vararg function safety not inferred
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Sep 22 05:13:51 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13508
--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to hsteoh from comment #1)
> Array vararg functions are not safe, because they take a slice of arguments
> on the stack. Example problem:
> -----
> class C {
> int[] data;
> this(int[] args...) {
> data = args; // oops: this.data now points to the stack...
> }
> }
> -----
I think that typesafe variadic parameters would be designed to be safe, because
the following case is correctly rejected by the compile time check.
int[] foo(int[] args...) {
return args; // Error: escaping reference to variadic parameter args
}
But as you know, current escape analysis mechanism is incomplete, and scope
attribute is yet not defined well.
--
More information about the Digitalmars-d-bugs
mailing list