Segfault with DMD optimization switch

Stephan stephan80 at mac.com
Wed Jan 23 14:15:12 PST 2013


On Wednesday, 23 January 2013 at 20:03:03 UTC, Walter Bright 
wrote:
> On 1/23/2013 8:06 AM, Jacob Carlborg wrote:
>> On 2013-01-23 08:50, Walter Bright wrote:
>>
>>> If your program has undefined behavior in it, the -O flag can 
>>> definitely
>>> cause that behavior to change.
>>
>> Yes, I guess that is to be expected. I'm mostly talking about 
>> correct code here.
>
> -O can especially expose code bugs like referencing an 
> out-of-scope stack frame.

This is a very good point, and I do think that there might be 
some mistake like that in my code, but it's definitely not 
obvious to me where. I did use delegates at some point, but in 
order to narrow down the causes, I changed that delegate to a 
functor, and the segfault still occurred.

What would be the prototypic short program that simulates 
referencing an out of scope stack frame? It would be great to see 
an example that produces a deterministic segfault.

Thanks, Stephan



More information about the Digitalmars-d mailing list