This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: trouble with -ffinite-math-only
- From: Ian Lance Taylor <iant at google dot com>
- To: Neal Becker <ndbecker2 at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 25 May 2010 07:41:33 -0700
- Subject: Re: trouble with -ffinite-math-only
- References: <htge7a$d1i$1@dough.gmane.org>
Neal Becker <ndbecker2@gmail.com> writes:
> gcc-4.4.3-4.fc12.x86_64
>
> I have some code that gives wrong results if compiled with -ffinite-math-
> only. I'm wondering what could cause this. I don't really expect any
> operations to produce NaN or Inf. Is it true that this behavior could only
> be explained if indeed some operation is producing NaN or Inf?
-ffinite-math by itself (i.e., without -ffast-math or
-funsafe-math-optimizations) should only enable optimizations which
assume that math operations never generate NaN or Inf. This is
mainly optimizations around comparisons of various sorts. If no NaN
can occur, the compiler has much more scope for optimizing floating
point comparisons. While bugs are always possible, I don't know of
any case where code that never generates a NaN or an Inf will change
behaviour with -ffinite-math-only.
Ian