On HP-UX 11.11, with CC="cc -Ae -O", I'm observing this test failure:
test-isfinite.c:54: assertion failed sh[10]: 1712 Abort(coredump) FAIL: test-isfinite The cause is that isfinite.c is miscompiled by "cc -O": The comparison x - x == 0 is "simplified" to x == x; this simplification is wrong for Infinity values. This patch avoids this bug: 2010-12-31 Bruno Haible <br...@clisp.org> isfinite: Avoid compiler bug of "cc -O" on HP-UX 11.11. * lib/isfinite.c (zerof, zerod, zerol): New variables. (gl_isfinitef, gl_isfinited, gl_isfinitel): Use them instead of literal zero. --- lib/isfinite.c.orig Sat Jan 1 03:49:46 2011 +++ lib/isfinite.c Sat Jan 1 03:44:20 2011 @@ -23,17 +23,30 @@ #include "isnand-nolibm.h" #include "isnanl-nolibm.h" +/* The "cc" compiler on HP-UX 11.11, when optimizing, simplifies the test + x - y == 0.0 to x == y, a simplification which is invalid when x and y + are Infinity. Disable this optimization. */ +#if defined __hpux && !defined __GNUC__ +static float zerof; +static double zerod; +static long double zerol; +#else +# define zerof 0.f +# define zerod 0. +# define zerol 0.L +#endif + int gl_isfinitef (float x) { - return !isnanf (x) && x - x == 0.f; + return !isnanf (x) && x - x == zerof; } int gl_isfinited (double x) { - return !isnand (x) && x - x == 0.; + return !isnand (x) && x - x == zerod; } int gl_isfinitel (long double x) { - return !isnanl (x) && x - x == 0.L; + return !isnanl (x) && x - x == zerol; }