Optimization (was Re: volatile)

Charles Marslett chasm at killer.UUCP
Wed Apr 27 15:20:25 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.

Actually, I have written code the broke with optimization turned on
on every machine I've found with a Unix-derived C compiler (and at least
two that are not Unix-derived).  Memory mapped I/O drivers almost always
blow up when you have sequences like

      port->data = 0;
      port->data = 0;
      port->data = 0;
      port->data = 2;

So are we to say that no one has yet written a C compiler?  At least for
Unices?

I may be picky, but if flags to the compiler should not change the semantics
of the language (in the broadest sense of the definition of semantics) -- what
good are they.  Why type the things in if they don't affect the generated
program (unless they triger off a pretty listing or play music while we
wait for errors, I guess ({:)  ).

Charles Marslett
chasm at killer.UUCP



More information about the Comp.lang.c mailing list