From: Bruno Haible Date: Mon, 6 Nov 2023 23:59:02 +0000 (+0100) Subject: nan: Work around clang's incorrect constant-folding on mips64. X-Git-Tag: v1.0~635 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=aa45ef321f53e30ef62eb1869b2a0a041f7addaa;p=gnulib.git nan: Work around clang's incorrect constant-folding on mips64. * lib/nan.h (NaNf, NaNd, NaNl): On mips platforms, avoid the compiler's constant-folding for 0.0f/0.0f, 0.0/0.0, 0.0L/0.0L. --- diff --git a/ChangeLog b/ChangeLog index d065d20be5..1103289bae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-11-06 Bruno Haible + + nan: Work around clang's incorrect constant-folding on mips64. + * lib/nan.h (NaNf, NaNd, NaNl): On mips platforms, avoid the compiler's + constant-folding for 0.0f/0.0f, 0.0/0.0, 0.0L/0.0L. + 2023-11-06 Bruno Haible snan: Add more info for mips-based platforms. diff --git a/lib/nan.h b/lib/nan.h index 4cb56350f8..219b25aeac 100644 --- a/lib/nan.h +++ b/lib/nan.h @@ -29,10 +29,11 @@ /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. - PGI 16.10 complains. */ + PGI 16.10 complains. clang 13 on mips64 does incorrect constant-folding. */ #if (defined __DECC || defined _MSC_VER \ - || (defined __MVS__ && defined __IBMC__) \ - || defined __PGI) + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI \ + || defined __mips__) static float NaNf () { @@ -48,10 +49,11 @@ NaNf () /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. - PGI 16.10 complains. */ + PGI 16.10 complains. clang 13 on mips64 does incorrect constant-folding. */ #if (defined __DECC || defined _MSC_VER \ - || (defined __MVS__ && defined __IBMC__) \ - || defined __PGI) + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI \ + || defined __mips__) static double NaNd () { @@ -69,14 +71,18 @@ NaNd () runtime type conversion. The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L. The IBM XL C compiler on z/OS complains. - PGI 16.10 complains. */ + PGI 16.10 complains. + Avoid possible incorrect constant-folding on mips. */ #ifdef __sgi static long double NaNl () { double zero = 0.0; return zero / zero; } -#elif defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +#elif (defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI \ + || defined __mips__) static long double NaNl () {