[Clang] Call to lambda expressions in unevaluated context is improperly rejected by Clang (original) (raw)

I'm not confident that I'm summarizing the issue accurately, but here is an example of the case that I discovered while at #70601.

template struct S { template using Type = decltype([] { return V(); }.template operator()()); };

S::Type V;

Clang currently rejects the above, complaining that there are no viable functions, which I think is suspicious.

:6:14: error: no matching member function for call to 'operator()' 4 | using Type = decltype([] { | ~~~~~~~~~~~~~ 5 | return V(); | ~~~~~~~~~~~ 6 | }.template operator()()); | ~~~~~~~~~~~^~~~~~~~~~~~~ :9:9: note: in instantiation of template type alias 'Type' requested here 9 | S::Type V; | ^ :4:25: note: candidate function template not viable: no known conversion from '(lambda at :4:25)' to 'const S::(lambda at :4:25)' for object argument 4 | using Type = decltype([] { | ^ 1 error generated.

The example is also on godbolt, and we can see that this is accepted by both MSVC and GCC.