document inconsistant?

Joe Buck jbuck@racerx.synopsys.com
Thu Mar 30 15:20:00 GMT 2000


> 
> Hi all,
>   I just used the following three CFLAGS to compile my program:
> 
> 1. -O2
> 2. -mcypress -O2
> 3. -msupersparc -O2
> 
>   and I got three different versions of the program.  Problem is that
> the
> program compiled with the first option simply generates a bus error.
> But the others are running fine.

This behavior is normal when you have a program that accesses uninitialized
memory.  The values you get will be semi-random, depending on the detailed
layout of the code.  While it is remotely possible that you've detected
a compiler problem, in 99.9%+ of cases of this kind, the bug is in your
program.

Another possibility is that you have code that relies on the order of
side effects, like

	bar = foo(i++, i++);

The order in which arguments to functions get evaluated is not defined in
C/C++ and can be chosen by the optimizer to be whatever is convenient.

gcc may be able to detect *some* problems in your code if you add the -Wall
switch, but lack of -Wall warnings is not a guarantee that you haven't
made a mistake of this kind.




More information about the Gcc mailing list