This is the mail archive of the gcc-help@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: trouble with -ffinite-math-only


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


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