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: unassig...@gcc.gnu.org
        ReportedBy: daniel.krueg...@googlemail.com
                CC: ja...@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).

Reply via email to