From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: Fix error in C++ mode on glibc systems
Date: Thu, 09 Feb 2023 13:21:24 +0100 [thread overview]
Message-ID: <2714877.YpNBiEq8W8@nimes> (raw)
When compiling a Gnulib testdir with clang15 with -std=gnu2x option,
on a CentOS 8 Stream system, I see this compilation error:
In file included from ../../gltests/test-nullptr-c++.cc:30:
In file included from ../../gltests/macros.h:22:
../gllib/stdlib.h:756:1: error: exception specification in declaration does not match previous declaration
_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ());
^
../gllib/wchar.h:238:23: note: expanded from macro '_GL_FUNCDECL_RPL'
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
^
<scratch space>:194:1: note: expanded from here
rpl_free
^
../gllib/wchar.h:698:19: note: previous declaration is here
_GL_EXTERN_C void rpl_free (void *);
^
1 error generated.
The cause is that on 2022-04-28 we added the 'throw ()' annotation to
the rpl_free declaration in stdlib.h.
https://lists.gnu.org/archive/html/bug-gnulib/2022-04/msg00072.html
But we have similar declarations also in malloc.h, string.h, wchar.h, and
they all need to be consistent.
This patch fixes it.
2023-02-09 Bruno Haible <bruno@clisp.org>
Fix error in C++ mode on glibc systems (regression 2022-04-28).
* lib/malloc.in.h (rpl_free): Add exception specification like
stdlib.in.h does.
* lib/string.in.h (rpl_free): Likewise.
* lib/wchar.in.h (rpl_free): Likewise.
diff --git a/lib/malloc.in.h b/lib/malloc.in.h
index 4921f6e994..2fcbe23535 100644
--- a/lib/malloc.in.h
+++ b/lib/malloc.in.h
@@ -65,7 +65,11 @@
# if (@REPLACE_FREE@ && !defined free \
&& !(defined __cplusplus && defined GNULIB_NAMESPACE))
/* We can't do '#define free rpl_free' here. */
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void rpl_free (void *) throw ();
+# else
_GL_EXTERN_C void rpl_free (void *);
+# endif
# undef _GL_ATTRIBUTE_DEALLOC_FREE
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
# else
diff --git a/lib/string.in.h b/lib/string.in.h
index aa08821392..b6bf432e1f 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -126,7 +126,11 @@
# if (@REPLACE_FREE@ && !defined free \
&& !(defined __cplusplus && defined GNULIB_NAMESPACE))
/* We can't do '#define free rpl_free' here. */
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void rpl_free (void *) throw ();
+# else
_GL_EXTERN_C void rpl_free (void *);
+# endif
# undef _GL_ATTRIBUTE_DEALLOC_FREE
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
# else
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index bbca92797d..2beddd780f 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -188,7 +188,11 @@ typedef int rpl_mbstate_t;
# if (@REPLACE_FREE@ && !defined free \
&& !(defined __cplusplus && defined GNULIB_NAMESPACE))
/* We can't do '#define free rpl_free' here. */
+# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void rpl_free (void *) throw ();
+# else
_GL_EXTERN_C void rpl_free (void *);
+# endif
# undef _GL_ATTRIBUTE_DEALLOC_FREE
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
# else
reply other threads:[~2023-02-09 12:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2714877.YpNBiEq8W8@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).