[Issue 24754] New: cannot take address of a member array in a ref foreach
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Sep  9 01:45:00 UTC 2024
    
    
  
https://issues.dlang.org/show_bug.cgi?id=24754
          Issue ID: 24754
           Summary: cannot take address of a member array in a ref foreach
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: contact at lsferreira.net
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`
```
--
    
    
More information about the Digitalmars-d-bugs
mailing list