https://github.com/Thibault-Monnier updated https://github.com/llvm/llvm-project/pull/180563
>From 2dc392f0259700bb0d030d1205a27b611c2133fb Mon Sep 17 00:00:00 2001 From: Thibault-Monnier <[email protected]> Date: Mon, 9 Feb 2026 18:12:28 +0100 Subject: [PATCH 1/4] Fix --- clang/lib/AST/ExprConstant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index d4068368f5b9d..0326273cd629a 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -9633,7 +9633,7 @@ bool LValueExprEvaluator::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) { if (Success) { Result.setFrom(Info.Ctx, Val); HandleLValueVectorElement(Info, E, Result, VT->getElementType(), - VT->getNumElements(), Index.getExtValue()); + VT->getNumElements(), Index.getZExtValue()); } return Success; >From 936c47ec2314056f4c7161141440bbd556ea5524 Mon Sep 17 00:00:00 2001 From: Thibault-Monnier <[email protected]> Date: Sat, 14 Feb 2026 13:08:00 +0100 Subject: [PATCH 2/4] Add test case and update ReleaseNotes --- clang/docs/ReleaseNotes.rst | 1 + clang/test/CodeGenCXX/vector.cpp | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 clang/test/CodeGenCXX/vector.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 0dbea8efc2642..5f360523afe37 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -274,6 +274,7 @@ Miscellaneous Clang Crashes Fixed - Fixed a crash when using loop hint with a value dependent argument inside a generic lambda. (#GH172289) - Fixed a crash in C++ overload resolution with ``_Atomic``-qualified argument types. (#GH170433) +- Fixed a crash when subscripting a vector type with large unsigned integer values. (#GH180563) OpenACC Specific Changes ------------------------ diff --git a/clang/test/CodeGenCXX/vector.cpp b/clang/test/CodeGenCXX/vector.cpp new file mode 100644 index 0000000000000..2a583afa197d2 --- /dev/null +++ b/clang/test/CodeGenCXX/vector.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s + +// CHECK: gh_180563 +int gh_180563(int __attribute__((vector_size(8))) v) { + return v[~0UL]; +} >From 3607a64ffcee8082ce0b78ea4228ea1cf1688939 Mon Sep 17 00:00:00 2001 From: Thibault-Monnier <[email protected]> Date: Thu, 26 Feb 2026 15:26:39 +0100 Subject: [PATCH 3/4] Address comments --- clang/test/CodeGenCXX/vector.cpp | 6 ------ clang/test/SemaCXX/vector.cpp | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 clang/test/CodeGenCXX/vector.cpp diff --git a/clang/test/CodeGenCXX/vector.cpp b/clang/test/CodeGenCXX/vector.cpp deleted file mode 100644 index 2a583afa197d2..0000000000000 --- a/clang/test/CodeGenCXX/vector.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s - -// CHECK: gh_180563 -int gh_180563(int __attribute__((vector_size(8))) v) { - return v[~0UL]; -} diff --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp index 744017304d121..ded0aab491fcc 100644 --- a/clang/test/SemaCXX/vector.cpp +++ b/clang/test/SemaCXX/vector.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify %s +// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -fexperimental-new-constant-interpreter %s // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++11 %s // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++20 %s @@ -476,6 +477,10 @@ struct PR45298Consumer { PR45298<T> s; }; + +constexpr int PR180563(int __attribute__((vector_size(8))) v) { + return v[~0UL]; +} #endif // __cplusplus >= 201103L void use() { >From 2d018a7f1a70af18806d74cc10892162d18a6f17 Mon Sep 17 00:00:00 2001 From: Thibault-Monnier <[email protected]> Date: Thu, 26 Feb 2026 17:04:05 +0100 Subject: [PATCH 4/4] Add static assert (requires C++17) --- clang/test/SemaCXX/vector.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp index ded0aab491fcc..355d93a2b8cee 100644 --- a/clang/test/SemaCXX/vector.cpp +++ b/clang/test/SemaCXX/vector.cpp @@ -477,10 +477,6 @@ struct PR45298Consumer { PR45298<T> s; }; - -constexpr int PR180563(int __attribute__((vector_size(8))) v) { - return v[~0UL]; -} #endif // __cplusplus >= 201103L void use() { @@ -537,6 +533,18 @@ void use() { } } // namespace PR48540 +#if __cplusplus >= 201703L // C++17 or later +namespace PR180563 { +typedef int __attribute__((vector_size(8))) v_int; +constexpr int f(v_int v) { + return v[~0UL]; // expected-note{{cannot refer to element 18446744073709551615 of array of 2 elements in a constant expression}} +} + +static_assert(f(v_int{0})); // expected-error{{static assertion expression is not an integral constant expression}} +// expected-note@-1{{in call to 'f({0, 0})'}} +} +#endif + #if __cplusplus >= 202002L // C++20 or later // Don't crash due to missing integer ranks. char8_t v1 __attribute__((vector_size(16))); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
