[clang] [Clang] Initialize AtLeastAsSpecialized to prevent undefined behavior… (PR #95195)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 11 21:42:19 PDT 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/95195
… in Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs()
This patch fixes a static analyzer bug where the boolean variable `AtLeastAsSpecialized` was used uninitialized. The variable is now explicitly initialized to false before its potential modification within a lambda function to ensure that it always holds a valid value when returned, preventing undefined behavior due to uninitialized variable usage in `Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs()`.
>From d73bb37285e7ec440fe5906d7b0e8177ab9d61cb Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Tue, 11 Jun 2024 21:38:47 -0700
Subject: [PATCH] [Clang] Initialize AtLeastAsSpecialized to prevent undefined
behavior in Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs()
This patch fixes a static analyzer bug where the boolean variable `AtLeastAsSpecialized` was used uninitialized. The variable is now explicitly initialized to false before its potential modification within a lambda function to ensure that it always holds a valid value when returned, preventing undefined behavior due to uninitialized variable usage in `Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs()`.
---
clang/lib/Sema/SemaTemplateDeduction.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index befeb38e1fe5b..df0d6908d0a78 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6447,7 +6447,7 @@ bool Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
if (Inst.isInvalid())
return false;
- bool AtLeastAsSpecialized;
+ bool AtLeastAsSpecialized = false;
runWithSufficientStackSpace(Info.getLocation(), [&] {
AtLeastAsSpecialized =
::FinishTemplateArgumentDeduction(
More information about the cfe-commits
mailing list