http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54812
Bug #: 54812 Summary: [C++11] Delete expression doesn't respect access of defaulted destructor Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: daniel.krueg...@googlemail.com CC: pa...@gcc.gnu.org While working on a further simplification of the is_constructible traits using gcc 4.8.0 20120930 (experimental) with the compiler flags -Wall -pedantic -std=c++11 the following program demonstrates that private access of a *defaulted* destructor is not properly respected during delete expressions: //-------------------- #include <new> template<class T> T&& declval(); struct P1 { private: ~P1(); }; struct P2 { ~P2() = delete; }; struct P3 { private: ~P3() = default; }; typedef decltype(::delete declval<P1*>()) t1; // #20 typedef decltype(::delete declval<P2*>()) t2; // #21 typedef decltype(::delete declval<P3*>()) t3; // #22 *Not* detected //-------------------- This program produces only two errors instead of the expected three: "main.cpp|8|error: 'P1::~P1()' is private| main.cpp|20|error: within this context| main.cpp|21|error: use of deleted function 'P2::~P2()'| main.cpp|12|error: declared here| " According to [expr.delete] p10 access control shall be done for the destructor.