clang is correct.
There's been some wrangling on this, but the construction of an object causes its destructor to be potentially invoked:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1424
So std::is_nothrow_default_constructible<X>
is not only testing the default constructor, but also ~X()
.
By default ~X()
has an implicit noexcept
applied to it. If your example either made ~X()
private or deleted it, or put a noexcept(false)
on it, then the static_assert
would fail.
I suspect that gcc 4.7.2 has not yet implemented the rule that destructors are implicitly noexcept
.
Update
I made a sweep of CWG/LWG issues while answering the above, but missed the obvious one:
http://cplusplus.github.com/LWG/lwg-active.html#2116
Thanks much to Cassio Neri for pointing this out below. Mea culpa for not picking this up myself. I would delete this answer except that I think the information it contains is perhaps helpful. Thank you Cassio Neri.