-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang] Call to lambda expressions in unevaluated context is improperly rejected by Clang #81145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-clang-frontend Author: Younan Zhang (zyn0217)
I'm not confident that I'm summarizing the issue accurately, but here is an example of the case that I discovered while at https://github.com//issues/70601.
```cpp
template <class T>
struct S {
template <class U>
using Type = decltype([]<class V> {
return V();
}.template operator()<U>());
};
S<int>::Type<int> V;
The example is also on godbolt, and we can see that this is accepted by both MSVC and GCC. |
I've traced the error and found that the issue occurs when we finish the template argument deduction. At this point, we're in the callback of We determine whether the argument type can be converted to the parameter type through some conversion sequences. Finally, we fail at this line in llvm-project/clang/lib/Sema/SemaOverload.cpp Lines 5729 to 5741 in 5452cbc
These two different types ought to correspond to the Lambda type before and after the llvm-project/clang/lib/Sema/TreeTransform.h Lines 14058 to 14091 in 5452cbc
There, we first try to convert the "BaseType", which is exactly this This is the discrepancy that causes the problem above, where I've spent some hours fixing this, but I have no luck yet. The approach that makes sense to me is to have llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp Lines 1482 to 1488 in 0802596
I tried to circumvent that by hoisting the Here is what I've done locally. #81150 |
Possibly related issue: #76674 |
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.
Clang currently rejects the above, complaining that there are no viable functions, which I think is suspicious.
The example is also on godbolt, and we can see that this is accepted by both MSVC and GCC.
The text was updated successfully, but these errors were encountered: