[clang] [clang] Fix partial specialization matching for NTTPs of placeholder type (PR #225239)

Valentyn Yukhymenko via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 23 12:51:40 PDT 2026


================
@@ -8040,7 +8040,10 @@ bool ASTContext::isSameTemplateArgument(const TemplateArgument &Arg1,
            getCanonicalTemplateName(Arg2.getAsTemplateOrTemplatePattern());
 
   case TemplateArgument::Integral:
-    return llvm::APSInt::isSameValue(Arg1.getAsIntegral(),
+    // The types have to match as well as the values:
+    // C++ [temp.type]p2
+    return hasSameType(Arg1.getIntegralType(), Arg2.getIntegralType()) &&
+           llvm::APSInt::isSameValue(Arg1.getAsIntegral(),
                                      Arg2.getAsIntegral());
----------------
BaLiKfromUA wrote:

Yes, I also came to similar solution here

https://github.com/llvm/llvm-project/pull/225239#discussion_r4067506719

But I am yet to double check that it's correct 

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


More information about the cfe-commits mailing list