Likely closure memory corruption

Brad Roberts braddr at puremagic.com
Sun Mar 10 13:21:45 PDT 2013


On 3/10/2013 12:11 PM, deadalnix wrote:
> On Friday, 8 March 2013 at 16:25:56 UTC, deadalnix wrote:
>> Sooooooo,
>>
>> 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;
>> }
>>
>> Very scary that I have to do that kind of things.
> 
> Is this a know bug ? Come on, this is a really bad bug, not the type of thing that can be ignored !

Is it in bugzilla?  The newsgroups are a bad place to be reporting bugs.


More information about the Digitalmars-d mailing list