This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."


On 2006-12-31 11:37:21 -0500, Richard Kenner wrote:
> Certainly.  Indeed I think that's the whole point of this thread: that if
> you want to catch ALL potential optimizations opportunities given to you
> by the standard, you must assume that signed overflows are undefined.
> 
> However, what's being discussed is an engineering tradeoff where you give
> up SOME optimization opportunities to avoid breaking code.

I was responding to a particular point. You said a few messages ago:

| I can't speak for any other GCC developer, but I personally am quite
| comfortable viewing any code that assumes wrapping semantics as broken
| and needing fixing with the exception of these cases of checking for
| overflow: there simply is no good way in C to do these checks in a portable
| manner and, as I said, I think we should make sure they continue to work
| and maybe even document that.

Now:

> Essentially, there are three choices: with -fwrapv, you must preseve
> wrapping semantics and do NONE of those optimizations; with
> -fno-wrapv, you can do ALL of them; in the default cause, a
> heuristic can be used that attempts to balance optimization quality
> against breakage of old code.

This isn't just about old code. If you're saying that old code with
overflow checking can't be fixed (in a portable manner...), then new
code will probably use the same tricks. Then hoping that such code
will continue to work is not sufficient. You need to really make sure
that it will still work. This means that either "overflow checking"
must be clearly defined, or -fwrapv should be used in any case (thus
disabling all the possible optimizations based on overflows). Well,
there's another way: a GCC extension so that the programmer can say
when wrapping is assumed.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]