Cannot access frame pointer of a struct with member function

Andrey Zherikov andrey.zherikov at gmail.com
Sun May 9 18:56:43 UTC 2021


On Sunday, 9 May 2021 at 17:53:07 UTC, SealabJaster wrote:
> On Sunday, 9 May 2021 at 17:37:40 UTC, Andrey Zherikov wrote:
>> Is this a bug?
>
> My best guess is that, since the struct doesn't have any member 
> functions the compiler has decided that the struct doesn't need 
> any access to the main function's context/frame pointer, so the 
> struct has implicitly become a `static struct`.
>
> Marking the struct `static` yourself while keeping the member 
> function, will show that it can then compile.
>
> You can also move your `foo` function into the main function 
> and it'll compile. Oddly the output ends up becoming: `T(1, 
> null)` which I didn't really expect.
>
> Just a guess though.

That's a point! Thanks you!


More information about the Digitalmars-d-learn mailing list