[clang] Fix assertion failure during conversion function overload resolution. (PR #98671)

Daniel M. Katz via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 12:31:15 PDT 2024


================
@@ -1519,7 +1519,8 @@ bool Sema::IsAtLeastAsConstrained(NamedDecl *D1,
     auto IsExpectedEntity = [](const FunctionDecl *FD) {
       FunctionDecl::TemplatedKind Kind = FD->getTemplatedKind();
       return Kind == FunctionDecl::TK_NonTemplate ||
-             Kind == FunctionDecl::TK_FunctionTemplate;
----------------
katzdm wrote:

@shafik Thanks for taking a look here!

I was able reverse engineer the following program which fails the assertion in question, due to removal of `TK_FunctionTemplate` from the list of "expected" Decls:

```cpp
template <typename T>
struct S {
  template <typename U=T>
    S(U={}) requires (^T != ^void) {}

  template <typename U=T>
    S(U={}) requires (^T != ^bool) {}
};


S<int> s;
```

@cor3ntin As per your original comment, I think this _does_ imply that the assertion is somewhat vacuous - it covers every non-dependent case (well, I guess the `TK_FunctionTemplate` case is sort of dependent too, but whatever).

Would it be better just to remove this assertion altogether, and perhaps to add the above snippet as a test for future reference? Let me know what y'all think would be best.

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


More information about the cfe-commits mailing list