This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54812] New: [C++11] Delete expression doesn't respect access of defaulted destructor
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 04 Oct 2012 14:37:11 +0000
- Subject: [Bug c++/54812] New: [C++11] Delete expression doesn't respect access of defaulted destructor
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
CC: paolo@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.