cc -O producing faulty code

John F Haugh II jfh at rpp386.cactus.org
Sun Jun 2 14:22:09 AEST 1991


In article <1991Jun1.065826.5526 at minyos.xx.rmit.oz.au> s900387 at minyos.xx.rmit.oz.au (Craig Macbride) writes:
>I have found a situation where a perfectly simple piece of C code which does
>some strcpy()s and fprintf()s works fine without the -O switch, but produces
>code which generates incorrect output when -O is used. (The code produced by
>the optimiser is also longer - I assume it's optimising for speed?)
>
>Has anyone else come across this situation on an RS6000 before? I always used
>to compile everything with -O on Unix machines, but it seems not a very safe
>thing to do with this compiler.

You need to give the level of the compiler that is failing as well as an
example of the code that breaks the optimizer.

I will start with the statement that most compiler bugs aren't.  I saw
quite a few things that were called "compiler bugs" that were really
caused by incorrect argument passing.  The proper argument just happened
to be in the correct register when optimization was turned off.

Now that I've said that, the S/6000 compiler has, in the past, had problems
with generating bad code with the optimizer turned on.  So far as I know,
the currently being delivered compiler has no such problems.  You need to
come up with the smallest fragment of (correct) code that reproduces the
problem and send it off to Defect Support.
-- 
John F. Haugh II        | Distribution to  | UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 255-8251 | GEnie PROHIBITED :-) |  Domain: jfh at rpp386.cactus.org
"If liberals interpreted the 2nd Amendment the same way they interpret the
 rest of the Constitution, gun ownership would be mandatory."



More information about the Comp.unix.aix mailing list