pointer escaping return scope bug?

Nick Treleaven nick at geany.org
Sat Nov 19 14:07:59 UTC 2022


Hi,
The following seems like a bug to me (reduced code, FILE* changed 
to int*):
```d
@safe:

struct LockedFile
{
     private int* fps;

     auto fp() return scope => fps;
}

void main()
{
     int* p;
     {
         auto lf = LockedFile(new int);
         p = lf.fp;
     }
     assert(p != null); // address escaped
}
```
There's no error with -dip1000.
I'll file this unless I overlooked something.


More information about the Digitalmars-d-learn mailing list