public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sbergman at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98305] New: Incomprehensible -Wmismatched-new-delete warning Date: Tue, 15 Dec 2020 22:10:25 +0000 [thread overview] Message-ID: <bug-98305-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98305 Bug ID: 98305 Summary: Incomprehensible -Wmismatched-new-delete warning Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sbergman at redhat dot com Target Milestone: --- With recent GCC 11 trunk (at git commit 8dede2411195eb2fd672d8d0c758f94732bd6d77): > $ cat test.cc > #include <cstddef> > template<typename> struct Reference {}; > template<typename> struct S2 { > static void * operator new(std::size_t); > static void operator delete(void *); > S2(); > }; > void f() { new S2<Reference<int>>; } > $ g++ -Wmismatched-new-delete -c test.cc > test.cc: In function ‘void f()’: > test.cc:8:16: warning: ‘static void S2< <template-parameter-1-1> >::operator delete(void*) [with <template-parameter-1-1> = Reference<int>]’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] > 8 | void f() { new S2<Reference<int>>; } > | ^~~~~~~~~~~~~~~~~~ > test.cc:8:16: note: returned from ‘static void* S2< <template-parameter-1-1> >::operator new(std::size_t) [with <template-parameter-1-1> = Reference<int>]’ (And oddly enough, the warning disappears when Reference is renamed to e.g. S1.)
next reply other threads:[~2020-12-15 22:10 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-15 22:10 sbergman at redhat dot com [this message] 2020-12-16 18:27 ` [Bug c++/98305] " msebor at gcc dot gnu.org 2020-12-16 18:27 ` msebor at gcc dot gnu.org 2020-12-17 2:11 ` [Bug c++/98305] spurious -Wmismatched-new-delete on template instance msebor at gcc dot gnu.org 2020-12-17 14:03 ` sbergman at redhat dot com 2021-01-06 20:46 ` cvs-commit at gcc dot gnu.org 2021-01-06 20:47 ` msebor at gcc dot gnu.org
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=bug-98305-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.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: linkBe 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).