[Bug c++/100485] False positive in -Wmismatched-new-delete

fiesh at zefix dot tv gcc-bugzilla@gcc.gnu.org
Mon May 10 06:53:10 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100485

--- Comment #5 from fiesh at zefix dot tv ---

> extern "C" void free (void *);
>   
> class Base
> {
> public:
>         Base();
> 
>         void * operator new(unsigned long, const int &);
>         void operator delete(void * ptr, const int &) {
>           #pragma GCC diagnostic ignored "-Wmismatched-new-delete"
>           free (ptr);
>         }
> };
> 
> void f()
> {
>         new (0) Base;
> }

Alas, keeping the diagnostic ignore local by means of `diagnostic push` /
`diagnostic pop` makes it not work correctly, presumably since the warning is
generated at the call site.  Making it global to everything including the
header file seems like a bad idea to me.


More information about the Gcc-bugs mailing list