[Issue 22539] [dip1000] slicing of returned ref scope static array should not be allowed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 27 20:08:37 UTC 2021


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

--- Comment #3 from Dennis <dkorpel at live.nl> ---
(In reply to Walter Bright from comment #2)
> I suspect the problem is actually this line:
> 
>     scope int*[1] x = [&stackVar];
> 
> Since scope is not transitive, allowing this causes the compiler to lose
> track of stack addresses, and will allow escapes.

Only if x were a slice, but since it's a static array with dimension 1 it is
identical to:

scope int* x = &stackVar;

So it is correctly permitted.

--


More information about the Digitalmars-d-bugs mailing list