public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: "周春明(日月)" <riyue.zcm@alibaba-inc.com>
Cc: Gdb-patches
	<gdb-patches-bounces+riyue.zcm=alibaba-inc.com@sourceware.org>,
	 Simon Marchi <simon.marchi@polymtl.ca>,
	gdb-patches <gdb-patches@sourceware.org>,
	Louis-He <1726110778@qq.com>,
	Dominique Quatravaux <dominique.quatravaux@epfl.ch>,
	Sam Warner <samuel.r.warner@me.com>
Subject: Re: ../../gdbsupport/new-op.cc:137:1: error: ‘void operator delete [](void*, std::size_t)’ is a usual (non-placement) deallocation function in C++14 (or with -fsized-deallocation) [-Werror=c++14-compat]
Date: Wed, 2 Mar 2022 16:30:56 +0000	[thread overview]
Message-ID: <20220302163056.GC1212730@redhat.com> (raw)
In-Reply-To: <65ee9ce9-34db-4434-9cc6-34378f96bee9.riyue.zcm@alibaba-inc.com>

* 周春明(日月) via Gdb-patches <gdb-patches@sourceware.org> [2022-03-01 15:48:47 +0800]:

> 
> Hi GDB maintainers,
> 
> I tried to build new GDB12, but encounter below error, anyone could tell me how to fix it? Thanks!
> 
>  CXX new-op.o
> ../../gdbsupport/new-op.cc:32:13: error: ‘void operator delete(void*, std::size_t)’ is a usual (non-placement) deallocation function in C++14 (or with -fsized-deallocation) [-Werror=c++14-compat]
>  extern void operator delete (void *p, std::size_t) noexcept;
>  ^
> ../../gdbsupport/new-op.cc:33:13: error: ‘void operator delete [](void*, std::size_t)’ is a usual (non-placement) deallocation function in C++14 (or with -fsized-deallocation) [-Werror=c++14-compat]
>  extern void operator delete[] (void *p, std::size_t) noexcept;
>  ^
> ../../gdbsupport/new-op.cc:119:1: error: ‘void operator delete(void*, std::size_t)’ is a usual (non-placement) deallocation function in C++14 (or with -fsized-deallocation) [-Werror=c++14-compat]
>  operator delete (void *p, std::size_t) noexcept
>  ^
> ../../gdbsupport/new-op.cc:137:1: error: ‘void operator delete [](void*, std::size_t)’ is a usual (non-placement) deallocation function in C++14 (or with -fsized-deallocation) [-Werror=c++14-compat]
>  operator delete[] (void *p, std::size_t) noexcept

I was able to reproduce this on Ubuntu 16.04.1 with their gcc 5.4.0.
I was unable to easily rebuild GCC 5.4.0 on my current development
machine to check if this is reproducible with upstream gcc, or is just
something impacting Ubuntu.  However, you can configure like:

  ../src/configure ...configure-flags-here... CXXFLAGS="-Wno-error=c++14-compat"

to disable this warning/error which I believe should be fine.

For why this error is occurring, I'm honestly not 100% sure what the
error is telling us.  I _think_ what it's saying is that the delete
operator that we're declaring/defining conflicts with a "usual
deallocation function", which is added in c++14 and means something
specific.  I guess the idea is that maybe we're just randomly defining
this version of delete for some reason, and then, if/when we move on
to c++14 this function will get called unexpectedly by the language
runtime in some situations.

As time moved on I think this warning was relaxed, possibly with this
commit:

  https://gcc.gnu.org/legacy-ml/gcc-patches/2015-05/msg01883.html

All this makes me wonder if the usual deallocation functions are ever
actually used, and indeed, I applied the patch below, and GDB still
seems to build fine, so this might be an alternative approach.  Maybe
we should commit this to master?

Thanks,
Andrew

---

diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc
index 1d066ba..4faa557 100644
--- a/gdbsupport/new-op.cc
+++ b/gdbsupport/new-op.cc
@@ -27,11 +27,6 @@
 #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
@@ -116,12 +111,6 @@ operator delete (void *p, const std::nothrow_t&) noexcept
 }
 
 void
-operator delete (void *p, std::size_t) noexcept
-{
-  return ::operator delete (p, std::nothrow);
-}
-
-void
 operator delete[] (void *p) noexcept
 {
   return ::operator delete (p);
@@ -133,10 +122,4 @@ operator delete[] (void *p, const std::nothrow_t&) noexcept
   return ::operator delete (p, std::nothrow);
 }
 
-void
-operator delete[] (void *p, std::size_t) noexcept
-{
-  return ::operator delete[] (p, std::nothrow);
-}
-
 #endif


  parent reply	other threads:[~2022-03-02 16:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  7:48 周春明(日月)
2022-03-01 14:32 ` Simon Marchi
2022-03-02  3:08   ` 回复:../../gdbsupport/new-op.cc:137:1: " 周春明(日月)
2022-03-02 16:45     ` Simon Marchi
2022-03-02 16:30 ` Andrew Burgess [this message]
2022-03-02 16:54   ` ../../gdbsupport/new-op.cc:137:1: " Simon Marchi
2022-03-02 17:03     ` Pedro Alves
2022-03-02 17:26       ` Simon Marchi
2022-03-02 17:43         ` Pedro Alves
2022-03-02 17:22     ` Andrew Burgess
2022-03-02 17:41       ` Simon Marchi
2022-03-03 12:27         ` Andrew Burgess
2022-03-03 14:18         ` Tom Tromey

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220302163056.GC1212730@redhat.com \
    --to=aburgess@redhat.com \
    --cc=1726110778@qq.com \
    --cc=dominique.quatravaux@epfl.ch \
    --cc=gdb-patches-bounces+riyue.zcm=alibaba-inc.com@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=riyue.zcm@alibaba-inc.com \
    --cc=samuel.r.warner@me.com \
    --cc=simon.marchi@polymtl.ca \
    /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).