https://github.com/Serosh-commits created 
https://github.com/llvm/llvm-project/pull/233138

When an invalid template parameter list is encountered while partially ordering 
template template arguments, finishing deduction can produce 
`NonDeducedMismatch` so treating this as a failed match instead of asserting 
that the template-template parameter is invalid
Fixes #227649

From cb0947634c41a24b761863b47be410467ef8e6c4 Mon Sep 17 00:00:00 2001
From: Serosh-commits <[email protected]>
Date: Sun, 18 Oct 2026 02:59:23 +0530
Subject: [PATCH] [clang] Handle invalid template template arguments in partial
 ordering

---
 clang/lib/Sema/SemaTemplateDeduction.cpp | 6 ++----
 clang/test/SemaTemplate/gh227649.cpp     | 6 ++++++
 2 files changed, 8 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/SemaTemplate/gh227649.cpp

diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1544fd56b82ae2..651114329d4e9e 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6609,11 +6609,9 @@ bool 
Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
   case TemplateDeductionResult::Success:
     return true;
 
-  // It doesn't seem possible to get a non-deduced mismatch when partial
-  // ordering TTPs, except with an invalid template parameter list which has
-  // a parameter after a pack.
+  // An invalid template parameter list can produce a non-deduced mismatch
+  // while finishing the deduction.
   case TemplateDeductionResult::NonDeducedMismatch:
-    assert(PArg->isInvalidDecl() && "Unexpected NonDeducedMismatch");
     return false;
 
   // Substitution failures should have already been diagnosed.
diff --git a/clang/test/SemaTemplate/gh227649.cpp 
b/clang/test/SemaTemplate/gh227649.cpp
new file mode 100644
index 00000000000000..02784971cb6907
--- /dev/null
+++ b/clang/test/SemaTemplate/gh227649.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+// CHECK: error: use of undeclared identifier 'foo'
+
+template <template <decltype(foo())> typename> struct S {};
+template <int &p> struct P;
+S<P> s;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to