On Friday, 13 December 2013 at 04:13:04 UTC, Kenji Hara wrote:
On Thursday, 12 December 2013 at 18:20:25 UTC, bearophile wrote:
If I have a function foo that takes a slice as input, and I want to pass it two arrays, the first time allocated on the heap and the second on the stack, I have to use an auxiliary variable:


void foo(int[]) {}
void main() {
   foo([1, 2, 3]);
   int[3] tmp = [4, 5, 6];
   foo(tmp);
}

There's a known issue that the function foo takes the slice of stack allocated data. Today some peoples argue that it is unsafe operation and should be disallowed in @safe code.

Kenji Hara

I think there is consensus that in @safe code this should be blocked.

Reply via email to