https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93700
Bug ID: 93700 Summary: new expression ignores deleted operator new. Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: maxim.yegorushkin at gmail dot com Target Milestone: --- The following code: struct C { C() { throw 1; } static void* operator new(unsigned long); static void operator delete(void*) = delete; }; C* f() { return new C; } Correctly fails to compile with clang: <source>:7:17: error: attempt to use a deleted function C* f() { return new C; } ^ <source>:4:10: note: 'operator delete' has been explicitly marked deleted here void operator delete(void*) = delete; ^ Whereas g++ simply ignores deleted `operator delete` and doesn't call it in the generated assembly at all. If that `operator delete` is commented out g++ does call the global `operator delete`.