https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109224
Arsen Arsenović <arsen at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Wmismatched-new-delete |Wmismatched-new-delete |false positive with |false positive with a |coroutines |templated operator new | |(common with coroutines) Keywords| |c++-coroutines --- Comment #4 from Arsen Arsenović <arsen at gcc dot gnu.org> --- non-coroutine reproducer: #include <new> #include <concepts> struct foo { template<typename... Args> requires (sizeof...(Args) == 0) void* operator new (std::size_t sz, Args&&...) { return ::operator new (sz); } void operator delete (void* x) { ::operator delete (x); } }; void f () { delete (new foo); } this fails because the mangled name of operator new contains template parameters whereas operator delete does not, so the code in new_delete_mismatch_p (const demangle_component&, const demangle_component&) that handles checking for mismatched operator names decides that they are different. I think that a class-specific operator delete can be called correctly for any class-specific operator new, so perhaps we ought to consider all operator new matching (ditto for class-specific new[]/delete[]). it should also be valid to call any sized operator delete for any operator new (ditto for new[]/delete[] again), I think. I'll try teaching new_delete_mismatch_p to throw away template arguments to the allocation fn as a start