[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] stdlib: make rpl_free declaration specification match the one in

From: Simon Marchi
Subject: [PATCH] stdlib: make rpl_free declaration specification match the one in string.h
Date: Thu, 28 Apr 2022 14:17:31 -0400

From: Simon Marchi <simon.marchi@efficios.com>

When building GDB on Ubuntu 20.04 (glibc 2.31) with clang++-14, I get:

    make[1]: Entering directory 
      CXX      agent.o
    In file included from /home/smarchi/src/binutils-gdb/gdbsupport/agent.cc:20:
    In file included from 
    ../gnulib/import/string.h:636:19: error: exception specification in 
declaration does not match previous declaration
    _GL_EXTERN_C void free (void *) throw ();
    ../gnulib/import/stdlib.h:737:17: note: expanded from macro 'free'
    #   define free rpl_free
    ../gnulib/import/stdlib.h:739:1: note: previous declaration is here
    _GL_FUNCDECL_RPL (free, void, (void *ptr));
    ../gnulib/import/sys/select.h:251:23: note: expanded from macro 
      _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
    <scratch space>:139:1: note: expanded from here

This started happening now that free gets replaced.

The issue seems to be that the free (rpl_free) declaration from string.h
has a throw() specification, but the rpl_free declaration in stdlib.h
does not.

Fix this by adding the same ifdef in stdlib.in.h as there is at
string.in.h:128, to conditionally include the throw() specification.
Not sure if this is right, but at least it fixes the build failure we


        * lib/stdlib.in.h (free): Conditionally add throw() exception
 lib/stdlib.in.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index d52c2f796382..a86643c3ca35 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -184,7 +184,11 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
 #   undef free
 #   define free rpl_free
 #  endif
+#  if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ());
+#  else
 _GL_FUNCDECL_RPL (free, void, (void *ptr));
+#  endif
 _GL_CXXALIAS_RPL (free, void, (void *ptr));
 # else
 _GL_CXXALIAS_SYS (free, void, (void *ptr));

base-commit: 1be44048ddb4c0b55c26818fb6e68f5d882fbf92

reply via email to

[Prev in Thread] Current Thread [Next in Thread]