]> Savannah Git Hosting - gnulib.git/commitdiff
totalorder, totalorderf: Avoid miscompilation by gcc on NetBSD/i386.
authorBruno Haible <bruno@clisp.org>
Tue, 9 Apr 2024 15:47:01 +0000 (17:47 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 19 Apr 2024 12:42:40 +0000 (14:42 +0200)
* lib/totalorder.c (totalorder): Use the a compiler optimization barrier
also for GCC.
* lib/totalorderf.c (totalorderf): Likewise.

ChangeLog
lib/totalorder.c
lib/totalorderf.c

index f946a276f33c9f4e0bd575d118894e1eac2bbcca..cbe1bad843fdbd3e5a37885d0096338f7e4ee457 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-09  Bruno Haible  <bruno@clisp.org>
+
+       totalorder, totalorderf: Avoid miscompilation by gcc on NetBSD/i386.
+       * lib/totalorder.c (totalorder): Use the a compiler optimization barrier
+       also for GCC.
+       * lib/totalorderf.c (totalorderf): Likewise.
+
 2024-04-09  Bruno Haible  <bruno@clisp.org>
 
        totalorder, totalorderf: Avoid miscompilation by clang on OpenBSD/i386.
index eaef9a582db255402318cf48d2c8d48cfff7ac0c..445b8f84d6b26bef6ad8eb2aadcf7fda143e0e2b 100644 (file)
@@ -57,9 +57,11 @@ totalorder (double const *x, double const *y)
   xu.f = *x;
   yu.f = *y;
 #else
-# ifdef __clang__
-  /* Prevent clang 16.0.6 on OpenBSD 7.5 from reusing the values of *x and *y
-     (fetched above) in optimized inlined memcpy expansions.  */
+# if defined __GNUC__ || defined __clang__
+  /* Prevent gcc and clang from reusing the values of *x and *y (fetched above)
+     in optimized inlined memcpy expansions.
+     Seen with gcc <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114659>
+     and with clang 16.0.6 on OpenBSD 7.5.  */
   __asm__ __volatile__ ("" : : : "memory");
 # endif
   /* On 32-bit x86 processors, as well as on x86_64 processors with
index f5f1b40112331627697ef6f3b32e23ba285711f8..70bc02cd90e68967dcd2ffd5889b21fee391df16 100644 (file)
@@ -57,9 +57,11 @@ totalorderf (float const *x, float const *y)
   xu.f = *x;
   yu.f = *y;
 #else
-# ifdef __clang__
-  /* Prevent clang 16.0.6 on OpenBSD 7.5 from reusing the values of *x and *y
-     (fetched above) in optimized inlined memcpy expansions.  */
+# if defined __GNUC__ || defined __clang__
+  /* Prevent gcc and clang from reusing the values of *x and *y (fetched above)
+     in optimized inlined memcpy expansions.
+     Seen with gcc <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114659>
+     and with clang 16.0.6 on OpenBSD 7.5.  */
   __asm__ __volatile__ ("" : : : "memory");
 # endif
   /* On 32-bit x86 processors, as well as on x86_64 processors with