Excessive optimization (was Re: what was VMS/OpenVMS written in?)

Guy Sotomayor ggs at shiresoft.com
Fri Dec 3 16:47:31 CST 2010


On Dec 3, 2010, at 2:42 PM, Fred Cisin wrote:

>>> I'm afraid I must disagree.  What if, for my own nefarious purposes, I
>>> need the N microseconds of delay achieved via the "spurious" for loop?
> 
> On Fri, 3 Dec 2010, Richard wrote:
>> Put that code in a compilation unit that is compiled with
>> optimizations turned off.
> 
> 
> Whether a programmer or a compiler produce better code would seem to
> depend on how well one can get the compiler to understand all of the
> details of what one WANTS the code to do, and just how weird THAT might
> be.  Some things, such as deliberately wasting time, or polling a memory
> location that is influenced externally, need additional explanation for
> the compiler to understand not to optimize them out.

See my previous post.  Using the volatile keyword on a variable requires the compiler to read/write it as expressed in the program (ie if in a loop, the compiler can't just read it once and be done).  If the compiler doesn't do that, it's a bug if it in any way claimed be a standards compliant compiler.

TTFN - Guy




More information about the cctalk mailing list