Likely closure memory corruption

Walter Bright newshound2 at digitalmars.com
Sun Mar 10 14:01:12 PDT 2013


On 3/8/2013 8:25 AM, deadalnix wrote:
> I have a struct. The struct have a context pointer. I have this method :
>
> @property
> auto save() inout {
>      return inout(Lexer)(t, r.save, line, index);
> }
>
> The context pointer IS NOT COPIED.
>
> Fixed it that way :
>
> @property
> auto save() inout {
>      // XXX: dmd bug, context pointer isn't copied properly
>      // doing it manualy using black magic.
>      // Context pointer is the last element of the struct. Here in position 9.
>      auto ret = inout(Lexer)(t, r.save, line, index);
>      (cast(void**) &ret)[9] = (cast(void**) &this)[9];
>
>      return ret;
> }

1. We can't do anything with code snippets like that. A complete, compilable 
example is necessary.

2. Such bug reports, along with the complete example demonstrating it, needs to 
go into bugzilla, not here.



More information about the Digitalmars-d mailing list