Optimization (was Re: volatile)

Lloyd Zusman ljz at fxgrp.uucp
Sat Apr 23 17:12:39 AEST 1988


In article <13074 at brl-adm.ARPA> dsill at NSWC-OAS.arpa (Dave Sill) writes:
>Terry Lambert writes:
>>Basically, if it works without -O, it should work with -O, regardless of what
>>the compiler writer's optimization does to achieve its goal.  If this makes
>>writing compilers harder, so what?
>
>This bears repeating.  There should be no circumstances under which
>the semantics of the language are changed by a flag to the compiler.
>
> ...

Wholehearted agreement!

This seems to imply ...

1)  No optimizer for C should be considered as conforming to ANSI standards
    unless, in so many words "... if it works with -O, it should work with
    -O, ..."

-or-

2)  Something like 'volatile' must exist.

Now, if the first option comes to pass, then 'volatile' is a moot point.
Methinks this is rather unlikely.

In the case of the second option, we still don't necessarily need 'volatile'
as currently specified.  Since the purpose of 'volatile' is to tell the
compiler something it needs to know about how to handle its optimization,
how about using

    #pragma volatile ...

instead?  This would satisfy those people who don't want the name space
cluttered with new keywords and also those people who need to protect
certain variables from over-zealous optimizers.

The ANSI committee could specify that the 'volatile' #pragma option either
does nothing (without generating an error) or else work as 'volatile'
is now specified.  Wouldn't this be more satisfactory than the current
proposal?

By the way, 'noalias' could be handled similarly.

--
    Lloyd Zusman
    Master Byte Software
    Los Gatos, California		Internet:   ljz at fxgrp.fx.com
    "We take things well in hand."	UUCP:	    ...!ames!fxgrp!ljz



More information about the Comp.lang.c mailing list