From: Paul Eggert Date: Sat, 2 Dec 2023 06:19:22 +0000 (-0800) Subject: frexp: pacify clang re address-of-volatile X-Git-Tag: v1.0~568 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a007cf68f0ee224d1d88cd6907f5dbea0ad5c149;p=gnulib.git frexp: 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. --- diff --git a/ChangeLog b/ChangeLog index c713de7b42..1a3429e03b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2023-12-01 Paul Eggert + 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. diff --git a/m4/frexp.m4 b/m4/frexp.m4 index 0293765c59..b23aa470c3 100644 --- a/m4/frexp.m4 +++ b/m4/frexp.m4 @@ -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; diff --git a/m4/frexpf.m4 b/m4/frexpf.m4 index 6f0565f803..661c29500e 100644 --- a/m4/frexpf.m4 +++ b/m4/frexpf.m4 @@ -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;