[clang] [Clang] prevent assertion failure for instantiation-dependent expressions in vector conversions (PR #173498)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 24 07:18:33 PST 2025
https://github.com/a-tarasyuk created https://github.com/llvm/llvm-project/pull/173498
Fixes #173347
---
This patch resolves an assertion failure that occurs when instantiation-dependent expressions are constant-evaluated during vector conversions.
>From c0f04c81e894914c85fbe66ca2298e4067280e74 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk <oleksandr.tarasiuk at outlook.com>
Date: Wed, 24 Dec 2025 16:56:48 +0200
Subject: [PATCH] [Clang] prevent assertion failure for instantiation-dependent
expressions in vector conversions
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/Sema/SemaExpr.cpp | 3 ++-
clang/test/SemaCXX/vector.cpp | 5 +++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8e2e45b8ef385..a39c98dd146c6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -614,6 +614,7 @@ Bug Fixes to C++ Support
- Fix the result of ``__is_pointer_interconvertible_base_of`` when arguments are qualified and passed via template parameters. (#GH135273)
- Fixed a crash when evaluating nested requirements in requires-expressions that reference invented parameters. (#GH166325)
- Fixed a crash when standard comparison categories (e.g. ``std::partial_ordering``) are defined with incorrect static member types. (#GH170015) (#GH56571)
+- Fixed an assertion failure in vector conversions involving instantiation-dependent template expressions. (#GH173347)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5a31b42541d99..69e5c8028f2ed 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10276,7 +10276,8 @@ static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S) {
/// IntTy without losing precision.
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int,
QualType OtherIntTy) {
- if (Int->get()->containsErrors())
+ Expr *E = Int->get();
+ if (E->containsErrors() || E->isInstantiationDependent())
return false;
QualType IntTy = Int->get()->getType().getUnqualifiedType();
diff --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp
index 06195f039cd92..744017304d121 100644
--- a/clang/test/SemaCXX/vector.cpp
+++ b/clang/test/SemaCXX/vector.cpp
@@ -799,3 +799,8 @@ template <int N> using templated_v_size = int __attribute__((vector_size(N)));
templated_v_size<-8> templated_v_neg_size; //expected-note{{in instantiation of template type alias 'templated_v_size' requested here}}
#endif
+
+namespace GH173347 {
+typedef short __attribute__((__vector_size__(8))) V;
+template <int N> V test(V x) { return (x % 5) * N; }
+}
More information about the cfe-commits
mailing list