Re: [PATCH] utimens: fix broken m4 test
Eric Blake wrote: > * m4/utimens.m4 (gl_UTIMENS): Include correct headers. ... > diff --git a/m4/utimens.m4 b/m4/utimens.m4 ... > +#include Thanks. That fixed it for me, too.
Re: icc bug on test-frexp-nolibm
On 11/03/2010 05:10 PM, Eric Blake wrote: > I'm running out of time today to get to the bottom of this, so if anyone > else wants to help out, great. If not, I'll see if I can resume testing > tomorrow and get a minimal test case that exposes the compiler bug, as > well as try and isolate ways to work around it. > > I'm on a Linux x86_64 machine with icc (ICC) 10.0 20070426. > > I hate it when a heisenbug disappears because of the mere act of adding > debugging hooks. :( I've reduced it to a minimal testcase: $ cat foo.c #define _GNU_SOURCE 1 #include #include double zero; double bar (void) { return -zero; } int main (void) { assert (!signbit (zero)); assert (signbit (bar ())); return 0; } $ icc -g -o foo foo.c $ ./foo $ icc-o foo foo.c $ ./foo foo: foo.c:9: main: Assertion `(( sizeof( bar () ) > sizeof( double )) ? __signbitl( (long double)(bar ()) ) : (( sizeof( bar () ) == sizeof( float )) ? __signbitf( (float)(bar ()) ) : __signbit( (double)(bar ()) )))' failed. Aborted (core dumped) $ Looks like icc with debugging computes -0.0 correctly, but without -g it makes a mistaken optimization. Comparing the assembly, I see: with -g: Dump of assembler code for function bar: 0x004005f8 <+0>: push %rbp 0x004005f9 <+1>: mov%rsp,%rbp 0x004005fc <+4>: sub$0x10,%rsp 0x00400600 <+8>: fldl 0x20087a(%rip)# 0x600e80 0x00400606 <+14>:fchs 0x00400608 <+16>:fstpl -0x10(%rbp) 0x0040060b <+19>:movsd -0x10(%rbp),%xmm0 0x00400610 <+24>:leaveq 0x00400611 <+25>:retq without -g: Dump of assembler code for function bar: 0x00400b3a <+0>: pxor %xmm0,%xmm0 0x00400b3e <+4>: subsd 0x203542(%rip),%xmm0# 0x604088 0x00400b46 <+12>:retq 0x00400b47 <+13>:nop Gnulib's testsuite already has several workarounds for computing -0.0 in spite of buggy compilers, so I think it's just a matter of making all the tests uniformly use those same workarounds. In particular, I tested that this works for icc regardless of whether CFLAGS includes -g (borrowing from test-ceill.c's workarounds for -0.0L as my starting point): #if defined __hpux || defined __sgi || defined __ICC static double compute_minus_zero (void) { return -DBL_MIN * DBL_MIN; } # define minus_zero compute_minus_zero () #else double minus_zero = -0.0; #endif -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
[PATCH 2/2] ceil, floor, round, trunc: enhance tests of -0
* tests/test-ceilf1.c (main): Ensure correct sign of result. * tests/test-ceill.c (main): Likewise. * tests/test-floorf1.c (main): Likewise. * tests/test-floorl.c (main): Likewise. * tests/test-round1.c (main): Likewise. * tests/test-roundf1.c (main): Likewise. * tests/test-roundl.c (main): Likewise. * tests/test-trunc1.c (main): Likewise. * tests/test-truncf1.c (main): Likewise. * tests/test-truncl.c (main): Likewise. Signed-off-by: Eric Blake --- In my minus_zero cleanups, I noticed that these tests were rather weak; it's possible that there are implementations that return 0.0 when they should be returning -0.0, so let's test that explicitly. The new checks should work even on systems that lack -0.0 (if there are any; I'm not convinced that SGI really lacks -0.0 on MIPS, so much as has a buggy compiler that doesn't expose it well, but I haven't recently logged on to an Irix machine to test this). ChangeLog| 12 modules/ceilf-tests |1 + tests/test-ceilf1.c |2 ++ tests/test-ceill.c |2 ++ tests/test-floorf1.c |2 ++ tests/test-floorl.c |2 ++ tests/test-round1.c |2 ++ tests/test-roundf1.c |2 ++ tests/test-roundl.c |2 ++ tests/test-trunc1.c |2 ++ tests/test-truncf1.c |2 ++ tests/test-truncl.c |2 ++ 12 files changed, 33 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9aca76a..01a4b39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2010-11-04 Eric Blake + ceil, floor, round, trunc: enhance tests of -0 + * tests/test-ceilf1.c (main): Ensure correct sign of result. + * tests/test-ceill.c (main): Likewise. + * tests/test-floorf1.c (main): Likewise. + * tests/test-floorl.c (main): Likewise. + * tests/test-round1.c (main): Likewise. + * tests/test-roundf1.c (main): Likewise. + * tests/test-roundl.c (main): Likewise. + * tests/test-trunc1.c (main): Likewise. + * tests/test-truncf1.c (main): Likewise. + * tests/test-truncl.c (main): Likewise. + frexp, tests: work around ICC bug with -zero * m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Compute -0.0 in a way that works with more compilers. diff --git a/modules/ceilf-tests b/modules/ceilf-tests index 040fd1b..a0472a7 100644 --- a/modules/ceilf-tests +++ b/modules/ceilf-tests @@ -9,6 +9,7 @@ tests/macros.h Depends-on: float isnanf-nolibm +signbit stdbool stdint diff --git a/tests/test-ceilf1.c b/tests/test-ceilf1.c index 86bb49e..4e38247 100644 --- a/tests/test-ceilf1.c +++ b/tests/test-ceilf1.c @@ -33,7 +33,9 @@ main () { /* Zero. */ ASSERT (ceilf (0.0f) == 0.0f); + ASSERT (!signbit (ceilf (0.0f))); ASSERT (ceilf (minus_zerof) == 0.0f); + ASSERT (!!signbit (minus_zerof) == !!signbit (ceilf (minus_zerof))); /* Positive numbers. */ ASSERT (ceilf (0.3f) == 1.0f); ASSERT (ceilf (0.7f) == 1.0f); diff --git a/tests/test-ceill.c b/tests/test-ceill.c index cac45b7..f627a9e 100644 --- a/tests/test-ceill.c +++ b/tests/test-ceill.c @@ -40,7 +40,9 @@ main () /* Zero. */ ASSERT (ceill (0.0L) == 0.0L); + ASSERT (!signbit (ceill (0.0L))); ASSERT (ceill (minus_zerol) == 0.0L); + ASSERT (!!signbit (minus_zerol) == !!signbit (ceill (minus_zerol))); /* Positive numbers. */ ASSERT (ceill (0.3L) == 1.0L); ASSERT (ceill (0.7L) == 1.0L); diff --git a/tests/test-floorf1.c b/tests/test-floorf1.c index 39261d8..f0f7716 100644 --- a/tests/test-floorf1.c +++ b/tests/test-floorf1.c @@ -33,7 +33,9 @@ main () { /* Zero. */ ASSERT (floorf (0.0f) == 0.0f); + ASSERT (!signbit (floorf (0.0f))); ASSERT (floorf (minus_zerof) == 0.0f); + ASSERT (!!signbit (minus_zerof) == !!signbit (floorf (minus_zerof))); /* Positive numbers. */ ASSERT (floorf (0.3f) == 0.0f); ASSERT (floorf (0.7f) == 0.0f); diff --git a/tests/test-floorl.c b/tests/test-floorl.c index 84717f8..2675a9e 100644 --- a/tests/test-floorl.c +++ b/tests/test-floorl.c @@ -40,7 +40,9 @@ main () /* Zero. */ ASSERT (floorl (0.0L) == 0.0L); + ASSERT (!signbit (floorl (0.0L))); ASSERT (floorl (minus_zerol) == 0.0L); + ASSERT (!!signbit (minus_zerol) == !!signbit (floorl (minus_zerol))); /* Positive numbers. */ ASSERT (floorl (0.3L) == 0.0L); ASSERT (floorl (0.7L) == 0.0L); diff --git a/tests/test-round1.c b/tests/test-round1.c index 86fd1de..4711a74 100644 --- a/tests/test-round1.c +++ b/tests/test-round1.c @@ -35,7 +35,9 @@ main () { /* Zero. */ ASSERT (round (0.0) == 0.0); + ASSERT (!signbit (round (0.0))); ASSERT (round (minus_zerod) == 0.0); + ASSERT (!!signbit (minus_zerod) == !!signbit (round (minus_zerod))); /* Positive numbers. */ ASSERT (round (0.3) == 0.0); ASSERT (round (0.5) == 1.0); diff --git a/tests/test-roundf1.c b/tests/test-roundf1.c index 33609bb..354dcf0 100644 --- a/tests/test-roundf1.c +++ b/tests/test-roundf1.c @@ -35,7 +35,9 @@ main () { /* Zero. */ ASSERT (roundf (0.0f) == 0.0f); + ASSERT (!sig
[PATCH 1/2] frexp, tests: work around ICC bug with -zero
* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Compute -0.0 in a way that works with more compilers. * tests/minus-zero.h: New file. * modules/ceilf-tests (Files): Include it. * modules/ceill-tests (Files): Likewise. * modules/floorf-tests (Files): Likewise. * modules/floorl-tests (Files): Likewise. * modules/frexp-nolibm-tests (Files): Likewise. * modules/frexp-tests (Files): Likewise. * modules/frexpl-nolibm-tests (Files): Likewise. * modules/frexpl-tests (Files): Likewise. * modules/isnan-tests (Files): Likewise. * modules/isnand-nolibm-tests (Files): Likewise. * modules/isnand-tests (Files): Likewise. * modules/isnanf-nolibm-tests (Files): Likewise. * modules/isnanf-tests (Files): Likewise. * modules/isnanl-nolibm-tests (Files): Likewise. * modules/isnanl-tests (Files): Likewise. * modules/round-tests (Files): Likewise. * modules/roundf-tests (Files): Likewise. * modules/roundl-tests (Files): Likewise. * modules/ldexpl-tests (Files): Likewise. * modules/signbit-tests (Files): Likewise. * modules/snprintf-posix-tests (Files): Likewise. * modules/sprintf-posix-tests (Files): Likewise. * modules/strtod-tests (Files): Likewise. * modules/trunc-tests (Files): Likewise. * modules/truncf-tests (Files): Likewise. * modules/truncl-tests (Files): Likewise. * modules/vsnprintf-posix-tests (Files): Likewise. * modules/vsprintf-posix-tests (Files): Likewise. * modules/vasnprintf-posix-tests (Files): Likewise. * modules/vasprintf-posix-tests (Files): Likewise. * tests/test-ceilf1.c (main): Use it. * tests/test-ceill.c (main): Likewise. * tests/test-floorf1.c (main): Likewise. * tests/test-floorl.c (main): Likewise. * tests/test-frexp.c (main): Likewise. * tests/test-frexpl.c (main): Likewise. * tests/test-isnan.c (main): Likewise. * tests/test-isnand.h (main): Likewise. * tests/test-isnanf.h (main): Likewise. * tests/test-isnanl.h (main): Likewise. * tests/test-ldexpl.c (main): Likewise. * tests/test-round.c (main): Likewise. * tests/test-roundf.c (main): Likewise. * tests/test-roundl.c (main): Likewise. * tests/test-signbit.c (test_signbitf, test_signbitd) (test_signbitl): Likewise. * tests/test-snprintf-posix.h (test_function): Likewise. * tests/test-sprintf-posix.h (test_function): Likewise. * tests/test-strtod.c (main): Likewise. * tests/test-trunc1.c (main): Likewise. * tests/test-truncf1.c (main): Likewise. * tests/test-truncl.c (main): Likewise. Signed-off-by: Eric Blake --- Refactors everything so that future compiler workarounds necessary to get at -0.0 can be limited to a single test file (.m4 files may need more efforts, though). Tested that all of these tests still pass with gcc; there are still some ICC failures, but I think they are due to NaN issues and not -0.0 issues (at any rate, I'll probably have more patches coming up later). ChangeLog | 59 + m4/frexp.m4| 18 -- modules/ceilf-tests|1 + modules/ceill-tests|1 + modules/floorf-tests |1 + modules/floorl-tests |1 + modules/frexp-nolibm-tests |2 + modules/frexp-tests|1 + modules/frexpl-nolibm-tests|2 + modules/frexpl-tests |1 + modules/isnan-tests|1 + modules/isnand-nolibm-tests|1 + modules/isnand-tests |1 + modules/isnanf-nolibm-tests|1 + modules/isnanf-tests |1 + modules/isnanl-nolibm-tests|1 + modules/isnanl-tests |1 + modules/ldexpl-tests |1 + modules/round-tests|1 + modules/roundf-tests |1 + modules/roundl-tests |1 + modules/signbit-tests |1 + modules/snprintf-posix-tests |1 + modules/sprintf-posix-tests|1 + modules/strtod-tests |1 + modules/trunc-tests|1 + modules/truncf-tests |1 + modules/truncl-tests |1 + modules/vasnprintf-posix-tests |1 + modules/vasprintf-posix-tests |1 + modules/vsnprintf-posix-tests |1 + modules/vsprintf-posix-tests |1 + tests/minus-zero.h | 70 tests/test-ceilf1.c|7 +--- tests/test-ceill.c | 19 +-- tests/test-floorf1.c |7 +--- tests/test-floorl.c| 19 +-- tests/test-frexp.c |7 +--- tests/test-frexpl.c| 19 +-- tests/test-isnan.c | 29 ++--- tests/test-isnand.h|7 +--- tests/test-isnanf.h|7 +--- tests/test-isnanl.h| 19 +-- tests/test-ldexpl.c| 19 +-- tests/test-round1.c|7 +--- tests/test-roundf1.c |7 +--- tests/test-roundl.c| 19 +-- tests/test-signbit.c | 35 tests/test-snprintf-posix.h| 33 --
[PATCH] isnanl: work around icc bug
* lib/isnan.c (FUNC): Compute run-time NaN under ICC as well. Signed-off-by: Eric Blake --- On a Linux x86_64 system where isnan() fails to recognize pseudo-nan long doubles, ICC 10.1 fails to compile isnan.c with: ../../gllib/isnan.c(133): error: floating-point operation result is out of range static memory_double nan = { L_(0.0) / L_(0.0) }; ^ ../../gllib/isnan.c(134): error: floating-point operation result is out of range static DOUBLE plus_inf = L_(1.0) / L_(0.0); ^ ../../gllib/isnan.c(135): error: floating-point operation result is out of range static DOUBLE minus_inf = -L_(1.0) / L_(0.0); ChangeLog |5 - lib/isnan.c |4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68c0a75..7f1a824 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -2010-11-03 Eric Blake +2010-11-04 Eric Blake + + isnan: work around icc bug + * lib/isnan.c (FUNC): Compute run-time NaN under ICC as well. tests: fix compiler warnings * tests/test-getopt.h (test_getopt): Fix condition. diff --git a/lib/isnan.c b/lib/isnan.c index ddad7fb..d183ac4 100644 --- a/lib/isnan.c +++ b/lib/isnan.c @@ -118,8 +118,8 @@ FUNC (DOUBLE x) /* Be careful to not do any floating-point operation on x, such as x == x, because x may be a signaling NaN. */ # if defined __TINYC__ || defined __SUNPRO_C || defined __DECC \ - || (defined __sgi && !defined __GNUC__) - /* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't + || (defined __sgi && !defined __GNUC__) || defined __ICC + /* The Sun C 5.0, Intel ICC 10.0, and Compaq (ex-DEC) 6.4 compilers don't recognize the initializers as constant expressions. The latter compiler also fails when constant-folding 0.0 / 0.0 even when constant-folding is not required. The SGI MIPSpro C compiler complains about "floating-point -- 1.7.3.2
Re: [PATCH 2/2] ceil, floor, round, trunc: enhance tests of -0
Eric Blake writes: > In my minus_zero cleanups, I noticed that these tests were rather > weak; it's possible that there are implementations that return 0.0 > when they should be returning -0.0, so let's test that explicitly. > The new checks should work even on systems that lack -0.0 (if there > are any; I'm not convinced that SGI really lacks -0.0 on MIPS, so > much as has a buggy compiler that doesn't expose it well, but I > haven't recently logged on to an Irix machine to test this). This looks good to me, for the "round" modules that I maintain. -- Ben Pfaff http://benpfaff.org
Re: [PATCH 1/2] frexp, tests: work around ICC bug with -zero
Eric Blake writes: > Refactors everything so that future compiler workarounds necessary > to get at -0.0 can be limited to a single test file (.m4 files may > need more efforts, though). Tested that all of these tests still > pass with gcc; there are still some ICC failures, but I think they > are due to NaN issues and not -0.0 issues (at any rate, I'll probably > have more patches coming up later). This looks fine to me for the "round" and "isnan" modules that I maintain. -- Ben Pfaff http://benpfaff.org