clang-concepts-monorepo icon indicating copy to clipboard operation
clang-concepts-monorepo copied to clipboard

Dependent class member access not correctly treated as lvalue in requires-expression

Open CaseyCarter opened this issue 5 years ago • 0 comments

In this well-formed TU (https://godbolt.org/z/EzMFaM):

template <class T, class U>
concept same_as = __is_same(T, U);

template <class T>
concept C = requires {
    { T::value } -> same_as<const int&>;
};

struct S {
    static constexpr int value = 42;
};

static_assert(C<S>); // "type constraint 'same_as<const int, const int &>' was not satisfied":

The final static_assert fires with the commented diagnostic. The compiler appears to incorrectly apply the type-constraint same_as_<const int&> to decltype(T::value) instead of decltype((T::value)) (See [expr.prim.req.compound]/1.3.2).

CaseyCarter avatar Sep 01 '19 15:09 CaseyCarter