[clang] Avoid accessing unset optional, workaround for #100095 (PR #100408)
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 08:46:16 PDT 2024
https://github.com/alexfh created https://github.com/llvm/llvm-project/pull/100408
This is not a proper fix, but enables Clang to continue working with more libc++ runtime checks enabled.
>From af5b5c114252cf1f6815b51871e2ad6436ffa723 Mon Sep 17 00:00:00 2001
From: Alexander Kornienko <alexfh at google.com>
Date: Wed, 24 Jul 2024 17:44:26 +0200
Subject: [PATCH] Avoid accessing unset optional, workaround for #100095
This is not a proper fix, but enables Clang to continue working with more libc++ runtime checks enabled.
---
clang/lib/Sema/SemaTemplateDeduction.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index b7b857ebf804b..db7f233dcef73 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -951,9 +951,11 @@ class PackDeductionScope {
// Skip over the pack elements that were expanded into separate arguments.
// If we partially expanded, this is the number of partial arguments.
+ // FIXME: `&& FixedNumExpansions` is a workaround for UB described in
+ // https://github.com/llvm/llvm-project/issues/100095
if (IsPartiallyExpanded)
PackElements += NumPartialPackArgs;
- else if (IsExpanded)
+ else if (IsExpanded && FixedNumExpansions)
PackElements += *FixedNumExpansions;
for (auto &Pack : Packs) {
More information about the cfe-commits
mailing list