[clang] [clang][constexpr] Fix assertion failure in C++26 constexpr structured binding pack evaluation (#170991) (PR #213534)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 5 11:47:31 PDT 2026
https://github.com/babadany2999 updated https://github.com/llvm/llvm-project/pull/213534
>From df8b767e50add27997edff472b2638f8fdb6def0 Mon Sep 17 00:00:00 2001
From: Baba Dan Constantin <babadany2999 at gmail.com>
Date: Sun, 2 Aug 2026 14:35:25 +0300
Subject: [PATCH] [clang][constexpr] Fix assertion failure in constexpr
structured binding pack evaluation (#GH170991)
---
clang/docs/ReleaseNotes.md | 3 +++
clang/lib/Sema/SemaDeclCXX.cpp | 2 ++
.../SemaCXX/cxx2c-binding-pack-constexpr-crash.cpp | 13 +++++++++++++
3 files changed, 18 insertions(+)
create mode 100644 clang/test/SemaCXX/cxx2c-binding-pack-constexpr-crash.cpp
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 7108392abbaa1..3d73e420fe5b4 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -424,6 +424,9 @@ features cannot lower the translation-unit ABI level;
copy so the union's object representation is copied, matching the defaulted
union copy constructor.
+- Fixed an assertion failure when evaluating C++26 `constexpr` structured binding packs during template
+ instantiation. (#GH170991)
+
#### Bug Fixes to AST Handling
- Fixed a non-deterministic ordering of unused local typedefs that made
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 47b01b913b428..ebc1d8ba0008f 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1701,6 +1701,8 @@ void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) {
// E or of the same unambiguous public base class of E, ...
if (checkMemberDecomposition(*this, Bindings, DD, DecompType, RD))
DD->setInvalidDecl();
+
+ CleanupVarDeclMarking();
}
UnsignedOrNone Sema::GetDecompositionElementCount(QualType T,
diff --git a/clang/test/SemaCXX/cxx2c-binding-pack-constexpr-crash.cpp b/clang/test/SemaCXX/cxx2c-binding-pack-constexpr-crash.cpp
new file mode 100644
index 0000000000000..7ce4c5216ac94
--- /dev/null
+++ b/clang/test/SemaCXX/cxx2c-binding-pack-constexpr-crash.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++26 %s
+
+namespace GH170991 {
+struct S { int x{}; };
+
+template <typename = void>
+void f() {
+ constexpr S s;
+ constexpr auto [...xs] = s;
+}
+
+template void f<void>();
+}
More information about the cfe-commits
mailing list