public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] [gdb/build] Fix build with -std=c++11
@ 2021-11-10 13:29 Tom de Vries
  2021-11-10 13:29 ` [PATCH 2/2] [gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build Tom de Vries
  2021-11-11 10:16 ` [PATCH 1/2] [gdb/build] Fix build with -std=c++11 Pedro Alves
  0 siblings, 2 replies; 12+ messages in thread
From: Tom de Vries @ 2021-11-10 13:29 UTC (permalink / raw)
  To: gdb-patches

When building with -std=c++11, we run into two Werror=missing-declarations:
...
new-op.cc: In function 'void operator delete(void*, std::size_t)':
new-op.cc:114:1: error: no previous declaration for \
  'void operator delete(void*, std::size_t)' [-Werror=missing-declarations]
 operator delete (void *p, std::size_t) noexcept
 ^~~~~~~~
new-op.cc: In function 'void operator delete [](void*, std::size_t)':
new-op.cc:132:1: error: no previous declaration for \
  'void operator delete [](void*, std::size_t)' [-Werror=missing-declarations]
 operator delete[] (void *p, std::size_t) noexcept
 ^~~~~~~~
...

These are due to recent commit 5fff6115fea "Fix
LD_PRELOAD=/usr/lib64/libasan.so.6 gdb".

The declarations are provided by <new> (which is included) for c++14 onwards,
but they are missing for c++11.

Fix this by adding the missing declarations.

Tested on x86_64-linux, with gcc 7.5.0, both without (implying -std=gnu++14) and
with -std=c++11.
---
 gdbsupport/new-op.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc
index 2f4c71457b1..716fa1a66de 100644
--- a/gdbsupport/new-op.cc
+++ b/gdbsupport/new-op.cc
@@ -27,6 +27,11 @@
 #include "host-defs.h"
 #include <new>
 
+/* These are declared in <new> starting C++14.  Add these here to enable
+   compilation using C++11. */
+extern void operator delete (void *p, std::size_t) noexcept;
+extern void operator delete[] (void *p, std::size_t) noexcept;
+
 /* Override operator new / operator new[], in order to internal_error
    on allocation failure and thus query the user for abort/core
    dump/continue, just like xmalloc does.  We don't do this from a

base-commit: b08625af20ade108868edd6f31d1cee68889a0df
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-11-15 20:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 13:29 [PATCH 1/2] [gdb/build] Fix build with -std=c++11 Tom de Vries
2021-11-10 13:29 ` [PATCH 2/2] [gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build Tom de Vries
2021-11-11 10:16   ` Pedro Alves
2021-11-11 10:16 ` [PATCH 1/2] [gdb/build] Fix build with -std=c++11 Pedro Alves
2021-11-11 11:41   ` Simon Marchi
2021-11-15 13:55     ` Tom de Vries
2021-11-15 14:05       ` Pedro Alves
2021-11-15 16:32         ` Simon Marchi
2021-11-15 16:43           ` Pedro Alves
2021-11-15 18:23             ` Simon Marchi
2021-11-15 18:42               ` Pedro Alves
2021-11-15 20:00                 ` Simon Marchi

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).