https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90629
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- With the patch I'm testing GCC reports the following for the test case in comment #2: 90629-c2.C: In function ‘void f()’: 90629-c2.C:8:16: warning: ‘void operator delete(void*, long unsigned int)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 8 | delete p; | ^ 90629-c2.C:7:33: note: returned from a call to ‘void* operator new [](long unsigned int)’ 7 | char * p = new char [ 10]; | ^ 90629-c2.C:11:19: warning: ‘void operator delete [](void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 11 | delete [] p2; | ^~ 90629-c2.C:10:25: note: returned from a call to ‘void* operator new(long unsigned int)’ 10 | char * p2 = new char; | ^~~~ 90629-c2.C:17:19: warning: ‘void operator delete [](void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 17 | delete [] q2; | ^~ 90629-c2.C:16:36: note: returned from a call to ‘void* malloc(size_t)’ 16 | char * q2 = (char *) malloc( 10); | ~~~~~~^~~~~ The call to free(q) isn't diagnosed in the simple test case because it's eliminated by the cddce pass along with the new expression.