[Issue 13508] array vararg function safety not inferred

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Sep 20 15:01:28 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13508

--- Comment #2 from monarchdodra 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...
>     }
> }
> -----

That's what I thought, but:
"If you mark "make" as explicitly safe, then it works."

So there's a loophole somewhere here.

Also related, I think it is a flaw that the very *signature* of something is
unsafe. In particular, the "array vararg" signature is *also* the one chosen
when you pass an array, which is perfectly defined and safe behavior...

--


More information about the Digitalmars-d-bugs mailing list