[Issue 24754] cannot take address of a member array in a ref foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 13 12:06:44 UTC 2024


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

--- Comment #13 from Nick Treleaven <nick at geany.org> ---
(In reply to Nick Treleaven from comment #3)
>     @safe
>     int* foobar()
>     {
>         int* f;
>         foreach(ref e; foo)
>             f = &e; // escaping address of foo[0]
>         return f;
>     }

BTW with dmd git master and -dip1000, the static array escape is now caught:

Error: scope variable `f` may not be returned

--


More information about the Digitalmars-d-bugs mailing list