DMD buggy optimizing

Walter Bright newshound at digitalmars.com
Fri Apr 28 23:51:43 PDT 2006


Dave wrote:
> Craig Black wrote:
>> Yes, but who knows when Walter will get around to fixing it?  Compler 
>> optimization is by nature complex and error prone.  I think being able 
>> to selectively optimize is a good idea.  This will allow us to 
>> identify optimization bugs more easily.

For about 999 cases out of 1000, the test case can be whittled down to 
10 or fewer lines of code, simply by whacking out stuff and seeing if 
the bug remains. Once the minimal test case is so identified, fixing it 
is usually not too bad.


> Yea, but that could substantially increase the complexity of the
> compiler and cause more bugs, not to mention how I'd hate to maintain D
> code marked up by all those "pragma-like" things, remove one, retest,
> remove another, retest, etc... <g>

The D optimizer is the same one as the DMC++ one that has been around 
for 20 years and several hundred thousand users. I run across an actual 
optimizer bug maybe once a year now. D benefits a lot from its maturity.

Many "optimizer" bugs turn out to be code bugs that exhibit different 
behavior when the optimizer rearranges things, hence it may appear to 
"work" unoptimized and fail optimized. The classic example of that is a 
wild pointer.



More information about the Digitalmars-d mailing list