https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67853

            Bug ID: 67853
           Summary: decltype of parenthesized xvalue does not correctly
                    yield rvalue-reference
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: t...@think-cell.com
  Target Milestone: ---

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.

Reply via email to