public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98305] New: Incomprehensible -Wmismatched-new-delete warning
@ 2020-12-15 22:10 sbergman at redhat dot com
  2020-12-16 18:27 ` [Bug c++/98305] " msebor at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sbergman at redhat dot com @ 2020-12-15 22:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

end of thread, other threads:[~2021-01-06 20:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 22:10 [Bug c++/98305] New: Incomprehensible -Wmismatched-new-delete warning sbergman at redhat dot com
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

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