https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87066
Bug ID: 87066 Summary: new expression and potential destructor invokation Product: gcc Version: 8.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: okannen at gmail dot com Target Milestone: --- In the c++ standard [expr.new]: >> if the new-expression creates an array of objects of class type, the >> destructor is potentially invoked. And potentially invoked means that it is odr-used [basic.odr.def]. Gcc seems to apply this rule chaotically: #include <string> struct A { ~A() = delete; std::string s; }; struct B { ~B() = delete; }; int main() { new A{}; //accepted new B{}; //error: use of deleted function ~B() //this is not a odr-use of ~B because this is not //an array creation new B; //accepted new B[1]{}; //wrongly accepted: array creation odr-use the deleted destructor new B[1]; //wrongly accepted: array creation odr-use the deleted }