[gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build When building with clang 13 (and -std=gnu++17 to work around an issue in string_view-selftests.c), we run into a few Wimplicit-exception-spec-mismatch warnings: ... src/gdbsupport/new-op.cc:102:1: error: function previously declared with an \ explicit exception specification redeclared with an implicit exception \ specification [-Werror,-Wimplicit-exception-spec-mismatch] operator delete (void *p) ^ /usr/include/c++/11/new:130:6: note: previous declaration is here void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ ... These are due to recent commit 5fff6115fea "Fix LD_PRELOAD=/usr/lib64/libasan.so.6 gdb". Fix this by adding the missing noexcept. Also fix a few Wmissing-prototypes warnings by adding the missing prototype. Build on x86_64-linux, using gcc 7.5.0 and clang 13.0.0. --- gdbsupport/new-op.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc index 2f4c71457b1..ac7bc146bf3 100644 --- a/gdbsupport/new-op.cc +++ b/gdbsupport/new-op.cc @@ -99,7 +99,7 @@ operator new[] (std::size_t sz, const std::nothrow_t&) noexcept errors from AddressSanitizers. */ void -operator delete (void *p) +operator delete (void *p) noexcept { free (p); } @@ -110,14 +110,19 @@ operator delete (void *p, const std::nothrow_t&) noexcept return ::operator delete (p); } +extern void +operator delete (void *p, std::size_t) noexcept; + void operator delete (void *p, std::size_t) noexcept { return ::operator delete (p, std::nothrow); } +extern void operator delete[] (void *p) noexcept; + void -operator delete[] (void *p) +operator delete[] (void *p) noexcept { return ::operator delete (p); } @@ -128,6 +133,8 @@ operator delete[] (void *p, const std::nothrow_t&) noexcept return ::operator delete (p, std::nothrow); } +extern void operator delete[] (void *p, std::size_t) noexcept; + void operator delete[] (void *p, std::size_t) noexcept {