]> Savannah Git Hosting - gnulib.git/commitdiff
nan: Work around clang's incorrect constant-folding on mips64.
authorBruno Haible <bruno@clisp.org>
Mon, 6 Nov 2023 23:59:02 +0000 (00:59 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 6 Nov 2023 23:59:02 +0000 (00:59 +0100)
* 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.

ChangeLog
lib/nan.h

index d065d20be5b17ec602b55144c0cc8a2b3f66e0e9..1103289bae6c69544ae67b4d0808b739096ad67d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-11-06  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        snan: Add more info for mips-based platforms.
index 4cb56350f8505b93172991f2430dbd794484adf1..219b25aeacb2a16decbb5423c0a2f790b00acbd8 100644 (file)
--- a/lib/nan.h
+++ b/lib/nan.h
 
 /* 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 ()
 {