On Fri, Nov 10, 2006 at 04:18:25PM -0800, Howard Chu wrote: > Richard Guenther wrote: > >If you compile with -O3 -combine *.c -o alias it will break. > > Hm, actually it still prints the correct result for me. What platform > are you using where it actually makes a difference?
Rather, he is saying that, with those flags, it is possible that gcc will do optimizations that breaks the code, but these optimizations might show up only on some platforms, with some releases, under some conditions. You might luck out, but it is possible that a future gcc will do an optimization that changes the meaning of the code. The compiler is allowed to reason roughly as follows: "I have a copy of foo in register R1. foo is of type long. There have been no writes, since foo was loaded into R1, for any types compatible with type long. Therefore the copy of foo in R1 is still good, so I don't have to reload it from memory." The C standard has rules of this form because, without them, it can be hard to do decent loop optimization. The reason Richard mentioned the options he did was that they enable some optimization across function boundaries, meaning that the compiler is more likely to see that there can't have been any legal modifications to some objects.