http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48872

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 
2011-05-04 17:38:16 UTC ---
(In reply to comment #0)

<sigh> an error happended when I tryied to transform my original example (using
std::declval) to a form with a minimum of library support. So let me provide
this fixed example and please ignore the first example:

gcc 4.7.0 20110430 (experimental) in C++0x mode rejects the following program:

//---------------
#include <new>

template<class T>
T&& create() noexcept;

struct U {
  ~U() noexcept(false);
};

constexpr bool b = noexcept(::new ((void*) 0) U(create<U&&>()));

static_assert(b, "Ouch"); // #

int main() {}
//---------------

The compiler rejects the line marked with # because of an assertion failure.
This happens in all cases where an U is placement-constructed with arguments as
with create<U&>() or with create<const U&>(). The example is accpted when only
value-initialized, like this:

constexpr bool b = noexcept(::new ((void*) 0) U());

This example demonstrates that the compiler seems to create a temporary in the
affected cases, so this is just another aspect of #48873.

Reply via email to