Skip to content

[Clang] Fix an assertion in the resolution of perfect matches #140073

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

Merged
merged 2 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions clang/include/clang/Sema/Overload.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,14 @@ class Sema;
if (!ReferenceBinding) {
#ifndef NDEBUG
auto Decay = [&](QualType T) {
return (T->isArrayType() || T->isFunctionType()) ? C.getDecayedType(T)
: T;
if (T->isArrayType() || T->isFunctionType())
T = C.getDecayedType(T);

// A function pointer type can be resolved to a member function type,
// which is still an identity conversion.
if (auto *N = T->getAs<MemberPointerType>())
T = C.getDecayedType(N->getPointeeType());
return T;
};
// The types might differ if there is an array-to-pointer conversion
// an function-to-pointer conversion, or lvalue-to-rvalue conversion.
Expand Down
19 changes: 19 additions & 0 deletions clang/test/SemaCXX/overload-resolution-deferred-templates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,22 @@ struct InitListAreNotPerfectCpy {
};

InitListAreNotPerfectCpy InitListAreNotPerfectCpy_test({InitListAreNotPerfectCpy{}});

namespace PointerToMemFunc {
template <typename>
class A;
struct N {
template <typename T>
void f(T);
};
template <typename T>
struct E {
template <class = A<int>>
void g() = delete;
void g(void (T::*)(char));
};
void f() {
E<N> e;
e.g(&N::f);
}
}
Loading