Member function increases size of a struct defined in a function - is this a bug?

Max Samukha maxsamukha at gmail.com
Fri Feb 7 12:50:11 UTC 2020


On Friday, 7 February 2020 at 12:36:23 UTC, Ferdinand Majerech 
wrote:

>
> Is this the result of some D feature?
> I can imagine this could happen if InnerFun had a silently 
> added context pointer, but I don't know of such a feature in D.
>

A pointer to the environment is a added to InnerFun for some 
reason (probably, a bug). You can work around by marking InnerFun 
'static':

void fun()
{
     static struct InnerFun
     {
         ubyte a;
         void fun() {}
     }
     ...
}


More information about the Digitalmars-d mailing list