From: Bruno Haible <bruno@clisp.org>
Date: Fri, 24 Nov 2023 19:02:37 +0000 (+0100)
Subject: floorf, ceilf tests: Strengthen against compiler optimizations.
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=103b72b097a97e0b51653a74f99c1677acaf7293;p=gnulib.git

floorf, ceilf tests: Strengthen against compiler optimizations.

Reported by René Rebe <rene@t2-project.org>.

* tests/test-floorf1.c (main): Mark my_floorf as 'volatile'.
* tests/test-floorf-ieee.c (main): Likewise.
* tests/test-ceilf1.c (main): Mark my_ceilf as 'volatile'.
* tests/test-ceilf-ieee.c (main): Likewise.
---

diff --git a/ChangeLog b/ChangeLog
index c49722723c..e1d4d9c655 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-11-24  Bruno Haible  <bruno@clisp.org>
+
+	floorf, ceilf tests: Strengthen against compiler optimizations.
+	Reported by René Rebe <rene@t2-project.org>.
+	* tests/test-floorf1.c (main): Mark my_floorf as 'volatile'.
+	* tests/test-floorf-ieee.c (main): Likewise.
+	* tests/test-ceilf1.c (main): Mark my_ceilf as 'volatile'.
+	* tests/test-ceilf-ieee.c (main): Likewise.
+
 2023-11-21  Bruno Haible  <bruno@clisp.org>
 
 	strerrorname_np: Work around glibc bug on HPPA systems.
diff --git a/tests/test-ceilf-ieee.c b/tests/test-ceilf-ieee.c
index 02edc0d92a..bfdceee1c5 100644
--- a/tests/test-ceilf-ieee.c
+++ b/tests/test-ceilf-ieee.c
@@ -38,7 +38,7 @@ dummy (float f)
 int
 main (int argc, _GL_UNUSED char **argv)
 {
-  float (*my_ceilf) (float) = argc ? ceilf : dummy;
+  float (* volatile my_ceilf) (float) = argc ? ceilf : dummy;
 
   /* See IEEE 754, section 6.3:
        "the sign of the result of the round floating-point number to
diff --git a/tests/test-ceilf1.c b/tests/test-ceilf1.c
index 61a4ae99b5..2ad2b30fb0 100644
--- a/tests/test-ceilf1.c
+++ b/tests/test-ceilf1.c
@@ -43,7 +43,7 @@ dummy (float f)
 int
 main (int argc, _GL_UNUSED char **argv)
 {
-  float (*my_ceilf) (float) = argc ? ceilf : dummy;
+  float (* volatile my_ceilf) (float) = argc ? ceilf : dummy;
 
   /* Zero.  */
   ASSERT (my_ceilf (0.0f) == 0.0f);
diff --git a/tests/test-floorf-ieee.c b/tests/test-floorf-ieee.c
index 32ceb5b7b1..8b1a02ac89 100644
--- a/tests/test-floorf-ieee.c
+++ b/tests/test-floorf-ieee.c
@@ -38,7 +38,7 @@ dummy (float f)
 int
 main (int argc, _GL_UNUSED char **argv)
 {
-  float (*my_floorf) (float) = argc ? floorf : dummy;
+  float (* volatile my_floorf) (float) = argc ? floorf : dummy;
 
   /* See IEEE 754, section 6.3:
        "the sign of the result of the round floating-point number to
diff --git a/tests/test-floorf1.c b/tests/test-floorf1.c
index b2787f6ff3..39b7a48432 100644
--- a/tests/test-floorf1.c
+++ b/tests/test-floorf1.c
@@ -43,7 +43,7 @@ dummy (float f)
 int
 main (int argc, _GL_UNUSED char **argv)
 {
-  float (*my_floorf) (float) = argc ? floorf : dummy;
+  float (* volatile my_floorf) (float) = argc ? floorf : dummy;
 
   /* Zero.  */
   ASSERT (my_floorf (0.0f) == 0.0f);