This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC optimizes integer overflow: bug or feature? (was: avoid integer overflow in mktime.m4)
- From: "Richard B. Kreckel" <kreckel at ginac dot de>
- To: <gcc at gcc dot gnu dot org>
- Cc: <bug-gnulib at gnu dot org>
- Date: Wed, 20 Dec 2006 00:10:59 +0100 (CET)
- Subject: Re: GCC optimizes integer overflow: bug or feature? (was: avoid integer overflow in mktime.m4)
- Reply-to: <Richard dot Kreckel at GiNaC dot DE>
On Mon, 18 Dec 2006, Andrew Pinski wrote:
> On Tue, 2006-12-19@06:54 +0100, Ralf Wildenhues wrote:
> > > Wheeeoo! That optimization is going to break a _lot_ of GNU
> > > software. (Silently. Oh my.)
>
> Just like say strict aliasing? :)
I find an analogy with -ffast-math much less far-fetched than one with
-fstrict-aliasing. Quoting from the GCC documentation:
This option [-ffast-math] should never be turned on by any `-O'
option since it can result in incorrect output for programs which
depend on an exact implementation of IEEE or ISO rules/specifications
for math functions.
C89 did not refer to IEEE 754 / IEC 60559. Yet, as far as I am aware,
-ffast-math or the implied optimizations have never been turned on by GCC
unless explicitly requested. That was a wise decision.
By the same token it would be wise to refrain from turning on any
optimization that breaks programs which depend on wrapping signed
integers. Silently breaking LIA-1 semantics is imprudent.
-richy.
--
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>