Article on overzealous compiler optimizations

Shammah Chancellor via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 23 04:26:12 PDT 2014


On 2014-06-22 19:32:45 +0000, Jonathan M Davis via Digitalmars-d said:

> On Friday, June 20, 2014 15:20:17 Walter Bright via Digitalmars-d wrote:
>> http://developers.slashdot.org/story/14/06/20/1824226/overeager-compilers-ca
>> n-open-security-holes-in-your-code
>> 
>> This is an opportunity for D to define the spec in such away as to preclude
>> the bad optimizations while keeping the good ones. Any ideas?
> 
> I applaud the sentiment, but I fear that I don't know enough about compiler
> optimizations to have much in the way of good ideas. It seems like every time
> the subject comes up, it turns out that compilers do all kinds of crazy things
> that make it so that half of what you think is guaranteed isn't guaranteed.
> If you had some way to mark code such that it restricts what the compiler can
> optimize, then that could help, but you'd have to know that you needed that
> restriction in the first place, and usually, the problem is that you don't
> even know what the compiler might optimize out, and not even checking the
> generated assembly helps in the general case, because what one compiler might
> leave in, another might optimize out. It's a thorny problem.
> 
> - Jonathan M Davis

Sounds like the oracle query optimizer.   95% of the time it does the 
right thing, but convincing it to behave the other 5% of the time is a 
real trick.

-Shammah



More information about the Digitalmars-d mailing list