https://github.com/Backl1ght created https://github.com/llvm/llvm-project/pull/96431
fixes https://github.com/llvm/llvm-project/issues/96205 The cause is that some `Conversions[ConvIdx]` here is not initialized https://github.com/llvm/llvm-project/blob/eb76bc38ffc286e62fdb8f8d897b5de04b2575be/clang/lib/Sema/SemaOverload.cpp#L7888-L7901 and we do not check whether `Cand->Conversions[I]` is initialized or not here. https://github.com/llvm/llvm-project/blob/eb76bc38ffc286e62fdb8f8d897b5de04b2575be/clang/lib/Sema/SemaOverload.cpp#L12148-L12158 >From f508b255f72e691908a625dc104c0624ab232f66 Mon Sep 17 00:00:00 2001 From: Backl1ght <backlight....@gmail.com> Date: Sun, 23 Jun 2024 21:44:03 +0800 Subject: [PATCH] fix --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaOverload.cpp | 2 +- clang/test/SemaCXX/lambda-call.cpp | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaCXX/lambda-call.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9c8f8c4a4fbaf..d13558040b7c0 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -915,6 +915,7 @@ Bug Fixes to C++ Support - Fix an assertion failure caused by parsing a lambda used as a default argument for the value of a forward-declared class. (#GH93512). - Fixed a bug in access checking inside return-type-requirement of compound requirements. (#GH93788). +- Fixed an assertion failure about invalid conversion when calling lambda. (#GH96205). Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index fb4ff72e42eb5..b866364028d09 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -12148,7 +12148,7 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, case ovl_fail_bad_conversion: { unsigned I = (Cand->IgnoreObjectArgument ? 1 : 0); for (unsigned N = Cand->Conversions.size(); I != N; ++I) - if (Cand->Conversions[I].isBad()) + if (Cand->Conversions[I].isInitialized() && Cand->Conversions[I].isBad()) return DiagnoseBadConversion(S, Cand, I, TakingCandidateAddress); // FIXME: this currently happens when we're called from SemaInit diff --git a/clang/test/SemaCXX/lambda-call.cpp b/clang/test/SemaCXX/lambda-call.cpp new file mode 100644 index 0000000000000..2c5b8b9a4b176 --- /dev/null +++ b/clang/test/SemaCXX/lambda-call.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++23 -verify -fsyntax-only %s + +namespace GH96205 { + +void f() { + auto l = [](this auto& self, int) -> void { self("j"); }; // expected-error {{no matching function for call to object of type}} \ + // expected-note {{no known conversion from 'const char[2]' to 'int'}} + l(3); // expected-note {{requested here}} +} + +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits