[clang] [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (PR #89934)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 19:03:40 PDT 2024


zyn0217 wrote:

> FYI in my issue, even if the lambda didn't appear as part of the default argument, I was [still able to trigger the bug](https://godbolt.org/z/4KrEMTTdd). Noting in case this fix only resolves the case of lambdas in default template arguments, and not passed in explicitly.
> 
> e.g.
> 
> ```c++
> static constexpr auto not_default_now = []<const char c> {
>     (void) static_cast<char>(c);
> };
> 
> template<auto Pred>
> using broken = decltype(Pred.template operator()<'\0'>());
> 
> broken<not_default_now>* boom;
> ```

Yeah, this patch *fixes* that as well. To clarify, the issue was caused by having extra template arguments in the context where we don't actually expect them. For example, the problem arose from the argument for `Pred` when it was substituted before we exercise `DeduceReturnType` for the lambda `not_default_now`. This patch now avoids that fault and only offers complete arguments relative to the primary template while checking constraints - this matches what our constraint checking expects.

https://github.com/llvm/llvm-project/pull/89934


More information about the cfe-commits mailing list