The following code snippet contains the parenthesized decltype of an xvalue: #include <type_traits> struct Member {}; struct A { Member x; }; A MakeA(); static_assert(std::is_same<decltype((MakeA().x)), Member&&>::value, ""); // MSVC++ 2015 //static_assert(std::is_same<decltype((MakeA().x)), Member>::value, ""); // clang, gcc The standard says in §7.1.6.2 about decltype(e) (4.1) [...] unparenthesized case, does not apply here (4.2) if e is an xvalue, decltype(e) is T&&, where T is the type of e; This means clang and gcc are not standard-conformant.
It seems as if the compiler still implements CWG 421 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#421 instead of the newer CWG 616: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#616
Fixed by r260621.
Author: mpolacek Date: Sun Jul 21 21:20:27 2019 New Revision: 273652 URL: https://gcc.gnu.org/viewcvs?rev=273652&root=gcc&view=rev Log: PR c++/67853 * g++.dg/cpp0x/decltype72.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/decltype72.C Modified: trunk/gcc/testsuite/ChangeLog
Test added.