[Issue 24754] cannot take address of a member array in a ref foreach
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 12 22:30:29 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24754
--- Comment #5 from Luís Ferreira <contact at lsferreira.net> ---
> If `&e` is the address of an int inside the `Foo.foo` array, then that is fine so long as the array is null or GC allocated.
Specification guarantees that only safe assignments are made, so, whatever is
assigned to `foo`, unless its `= void` assignment, its safe to de-reference it,
again, as long as the assignment is safe.
> However, if Foo.foo is changed to `int[1] foo;`, it still won't error and it should
The code you presented escapes variables. The code I presented doesn't escape
anything beyond its own scope, which is conceptually not escaping. Escaping is
defined via DIP1000, and I'm not expecting the code to compile when escaping
without defining `return` attribute to the member function.
--
More information about the Digitalmars-d-bugs
mailing list