On Wed, Dec 7, 2016 at 5:36 PM, Roland Haas <rhaas@illinois.edu> wrote:
Hello Erik,

> Cactus offers functions "CCTK_isnan" etc. that always do what the name
> suggests, so that compilers can optimize "isnan" away if they want.
Are you sure about this? I have (in src/util/Math.c):

--8<--
int CCTK_isnan(double x)
{
#ifdef HAVE_ISNAN
  return isnan(x);
#else
  return 0;                     /* default */
#endif
}
--8<--
and -ffinite-math-only turns isnan into a no-op that always returns
"true".

HAVE_ISNAN is set by the configure script. NaNChecker uses CCTK_isnan
yet it failed on machines using unbuntu.cfg which uses -ffast-math
(which includes -ffinite-math-only).

When I checked, only C++ compilers replaced "isnan", not C compilers, thus redirecting C++ calls to this C function worked fine. If this doesn't work any more then we'll have to be more clever and examine the bit pattern. (We can do this even in a header file, we then don't need the C implementation file any more.)

-erik

--