]> Savannah Git Hosting - gnulib.git/commitdiff
frexp: pacify clang re address-of-volatile
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 2 Dec 2023 06:19:22 +0000 (22:19 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 2 Dec 2023 06:36:06 +0000 (22:36 -0800)
Problem reported by Sam James in:
https://lists.gnu.org/r/bug-gnulib/2023-12/msg00013.html
* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Don’t try to convert
‘double volatile *’ to ‘void const *’ as the C standard
doesn’t allow accessing volatile variables through
pointer-to-nonvolatile.
* m4/frexpf.m4 (gl_FUNC_FREXPF_WORKS): Likewise.

ChangeLog
m4/frexp.m4
m4/frexpf.m4

index c713de7b428b718c10415bb1729a779ff54fd2d2..1a3429e03b639f715ff8ce3094a45454e6d563cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2023-12-01  Paul Eggert  <eggert@cs.ucla.edu>
 
+       frexp, frexpf: pacify clang re address-of-volatile
+       Problem reported by Sam James in:
+       https://lists.gnu.org/r/bug-gnulib/2023-12/msg00013.html
+       * m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Don’t try to convert
+       ‘double volatile *’ to ‘void const *’ as the C standard
+       doesn’t allow accessing volatile variables through
+       pointer-to-nonvolatile.
+       * m4/frexpf.m4 (gl_FUNC_FREXPF_WORKS): Likewise.
+
        Update portability doc for CHERI, C23
        * doc/gnulib-readme.texi:
        Prefer “null pointer” to “@code{NULL}” since C23 has nullptr.
index 0293765c5924f6a0225bbfccf4f7d49c019848a4..b23aa470c3a9bf7ff6b7fcc51ec10154230e4e8a 100644 (file)
@@ -1,4 +1,4 @@
-# frexp.m4 serial 18
+# frexp.m4 serial 19
 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -156,7 +156,8 @@ int main()
   {
     int exp;
     double y = frexp (x, &exp);
-    if (memcmp (&y, &x, sizeof x))
+    double x1 = x;
+    if (memcmp (&y, &x1, sizeof x1))
       result |= 4;
   }
   return result;
index 6f0565f8037435d49b650f2294b5d04fd29efdfc..661c29500ea6a156b8f0fbea8d4628de6945a3b0 100644 (file)
@@ -1,4 +1,4 @@
-# frexpf.m4 serial 8
+# frexpf.m4 serial 9
 dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -80,7 +80,8 @@ int main()
   {
     int exp;
     float y = frexpf (x, &exp);
-    if (memcmp (&y, &x, sizeof x))
+    float x1 = x;
+    if (memcmp (&y, &x1, sizeof x1))
       result |= 2;
   }
   return result;