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 <ale...@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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits