-ffast-math: Math critical applications?

Jim Gettys jg at laptop.org
Wed Oct 4 18:27:27 EDT 2006


Fundamentally --fast-math is not safe to use unless you are quite sure
you don't have any precision limitations of calculations.

Generally, fast math means things like "don't bother to do gradual
underflow" per the IEEE spec, avoiding traps and the like to handle such
cases.  So this only bites you in corner cases (and IEEE math was
defined to "get the right answer" by default, rather than having bridges
fall down).
                                  - Jim


On Wed, 2006-10-04 at 15:24 -0700, Robin H. Johnson wrote:
> On Wed, Oct 04, 2006 at 03:35:12PM -0400, John Richard Moser wrote:
> > Currently of interest to me is applying -ffast-math generally.  This
> > should not be a problem in most cases; -ffast-math only produces defects
> > in floating point calculations, and the defects are apparently often
> > minor enough to go unnoticed.  Critical calculations like TCP/IP packet
> > size, byte offsets in files, and physical pixel locations are all
> > discrete anyway and thus will all be integer.
> This is a slight tangent to your original point, but it came up recently
> with regards to -ffast-math, and is related to your correctness
> questions below.
> 
> The one sentence background is that I'm a Gentoo developer.
> 
> In the last month, I've seen several separate Gentoo bugs filed for
> cases where -ffast-math was causing incorrect operation or outright
> segmentation faults - with a stable GCC.
> 
> We're putting an item into our next GWN, but a quick survey of Gentoo
> developers indicated that -ffast-math has broken a lot of stuff in the
> past: openssl, libmcrypt, kde-libs, openoffice, apache2, postgresql,
> mpfr, gmp, nss_ldap (a subset of the complete list).
> 
> For openssl, mcrypt, mpfr and gmp, the applications had decent
> testsuites, and the bug was easy to catch, but in the other cases it
> wasn't caught until much later.
> 
> _______________________________________________
> Devel mailing list
> Devel at laptop.org
> http://mailman.laptop.org/mailman/listinfo/devel
-- 
Jim Gettys
One Laptop Per Child





More information about the Devel mailing list