[Issue 23032] New: passing nested structs to struct templates which make them static should be a warning

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 17 19:02:47 UTC 2022


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

          Issue ID: 23032
           Summary: passing nested structs to struct templates which make
                    them static should be a warning
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: crazymonkyyy at gmail.com

```d
import std;
struct framelaundering(FRAME){
        static FRAME main;
        ref i(){return main.j;}
}
void main(){
        int i;
        struct here{
                ref j(){return i;}
        }
        framelaundering!here foo;
        foo.i++;
        i.writeln;
}
```

causes a runtime crash; whats happening to the otherwise magic static keyword
was extremely unclear to me.

Id suggest a warning "here from main.here has a context pointer, when its used
in framelaundering!here.main is initialed without it because its static" or
sometin

--


More information about the Digitalmars-d-bugs mailing list