llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Zhikai Zeng (Backl1ght)

<details>
<summary>Changes</summary>

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-&gt;Conversions[I]` is initialized or not 
here.

https://github.com/llvm/llvm-project/blob/eb76bc38ffc286e62fdb8f8d897b5de04b2575be/clang/lib/Sema/SemaOverload.cpp#L12148-L12158


---
Full diff: https://github.com/llvm/llvm-project/pull/96431.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+1-1) 
- (added) clang/test/SemaCXX/lambda-call.cpp (+11) 


``````````diff
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}}
+}
+
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/96431
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to