-
-
Notifications
You must be signed in to change notification settings - Fork 701
cannot take address of a member array in a ref foreach #18267
Copy link
Copy link
Closed
Labels
Description
Luís Ferreira reported this on 2024-09-09T01:45:00Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=24754
CC List
- Richard (Rikki) Andrew Cattermole
- Dennis
- Dominikus Dittes Scherkl
- Nick Treleaven (@ntrel)
Description
The following code should compile:
```
struct Foo
{
int[] foo;
@safe
void foobar()
{
int* f;
foreach(ref e; foo)
f = &e;
}
}
void main()
{
Foo foo;
foo.foobar();
}
```
Shouldn't yield:
```
Up to 2.078.3: Failure with output: onlineapp.d(10): Error: cannot take address of local e in @safe function foobar
Since 2.079.1: Failure with output: onlineapp.d(10): Error: cannot take address of local `e` in `@safe` function `foobar`
```Reactions are currently unavailable