DMD buggy optimizing

James Dunne james.jdunne at gmail.com
Fri Apr 21 19:52:45 PDT 2006


Michael wrote:
> Is it possible to mark a certain section of code as not optimizing? My program
> works fine in debug mode but then when I use the release build it refuses to
> work, and there is no way for me to debug it either.
> 
> If we could mark a certain section of code as "dont optimize" then this would
> solve the problem. I know rougly where the problem is, but not exactly.
> 
> 

A quick answer to your problem would be to mark the code as volatile. 
Like so:

volatile {
	my += code;
	that.should(not);
	be.optimized!();
}

I'm not sure if this actually *does* turn off optimization for the code 
in question, but in general it would be a bad idea for a compiler to 
apply optimizations to volatile code.  I'll have to check the DMD 
implementation for this later.

-- 
Regards,
James Dunne



More information about the Digitalmars-d mailing list