Cannot access frame pointer of a struct with member function

Andrey Zherikov andrey.zherikov at gmail.com
Sun May 9 17:37:40 UTC 2021


Compilation of this code:
```d
auto foo(T)()
{
     return T();   // Error: cannot access frame pointer of 
`onlineapp.main.T`
}

void main()
{
     struct T
     {
         int a=1;
         void argsFunc(int a) {} // (1)
     }

     pragma(msg,foo!T());
}
```
fails with this error:
```
onlineapp.d(3): Error: cannot access frame pointer of 
`onlineapp.main.T`
onlineapp.d(14): Error: template instance `onlineapp.foo!(T)` 
error instantiating
onlineapp.d(14):        while evaluating `pragma(msg, foo!(T)())`
```
But when I comment out argsFunc function on line (1), it compiles 
successfully meaning that there is no issue to access frame 
pointer.

Is this a bug?


More information about the Digitalmars-d-learn mailing list