From: Paul Eggert Date: Sat, 2 Dec 2023 06:19:22 +0000 (-0800) Subject: frexp: pacify clang re address-of-volatile X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=06c737a7c85da324d7fb51a6b05baa6bbd901fb4;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 49fdf2c845..103d66e0d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +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. + 2023-12-01 Bruno Haible obstack: Avoid undefined behaviour. diff --git a/m4/frexp.m4 b/m4/frexp.m4 index 0480d98f30..c9e61e942d 100644 --- a/m4/frexp.m4 +++ b/m4/frexp.m4 @@ -1,4 +1,4 @@ -# frexp.m4 serial 16 +# frexp.m4 serial 16.1 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 94a7ef6801..57c6462cad 100644 --- a/m4/frexpf.m4 +++ b/m4/frexpf.m4 @@ -1,4 +1,4 @@ -# frexpf.m4 serial 6 +# frexpf.m4 serial 6.1 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;