Posted Apr 17, 2008 17:24 UTC (Thu) by clugstj (subscriber, #4020)
In reply to: Solution by proski
Parent article: GCC and pointer overflows
OK, how about this: if you don't trust the code, don't use the latest whiz bang optimizations!
The documentation for GCC should specifically warn about optimizations that can do bad things
with questionable code. As an example, here is a quote from the "Sun Workshop 6 update 2" man
page:
-xO3 In addition to optimizations performed at the
-xO2 level, also optimizes references and
definitions for external variables. This
level does not trace the effects of pointer
assignments. When compiling either device
drivers that are not properly protected by
volatile, or programs that modify external
variables from within signal handlers, use
-xO2
Let's not penalize GCC because of how some people will use/abuse it.