clang-concepts-monorepo
clang-concepts-monorepo copied to clipboard
Dependent class member access not correctly treated as lvalue in requires-expression
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).