[Bug c++/48873] New: [C++0x][noexcept] Placement-new problem with deleted destructors
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Wed May 4 15:46:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48873
Summary: [C++0x][noexcept] Placement-new problem with deleted
destructors
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
CC: jason@redhat.com
gcc 4.7.0 20110430 (experimental) in C++0x mode rejects the following program:
//--------------------------
#include <new>
struct D {
~D() = delete;
};
template<class T>
T&& create();
const bool b = noexcept(::new (((void*) 0)) D(create<D&&>())); // #
int main() {}
//--------------------------
At the line marked with # we get:
"error: use of deleted function 'D::~D()'"
The same error occurs with example arguments like create<D&>() or create<const
D&>(), but the program becomes accepted (as expected), if the initializer list
of D is empty, i.e. if we use the noexcept expression:
noexcept(::new (((void*) 0)) D())
instead to initialize b.
The program should be accepted in either case, because no effective destructor
call is going on here (no temporary is produced).
More information about the Gcc-bugs
mailing list