[go: up one dir, main page]

|
|
Log in / Subscribe / Register

Solution

Solution

Posted Apr 17, 2008 15:27 UTC (Thu) by proski (guest, #104)
In reply to: Solution by clugstj
Parent article: GCC and pointer overflows

Bugs exist not only in old crusty code. Just because the code was written recently, it doesn't make the code better or safer. Even if the code was developed with the new compiler but was not specifically tested for overflows, it still can have that problem.


to post comments

Solution

Posted Apr 17, 2008 17:24 UTC (Thu) by clugstj (subscriber, #4020) [Link]

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.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds