[clang] 4502187 - [clang][bytecode] Fix a crash with an invalid Descriptor (#224231)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 17 04:04:35 PDT 2026
Author: Timm Baeder
Date: 2026-09-17T13:04:30+02:00
New Revision: 4502187e2dde66d801d89f156dc47cc70509068f
URL: https://github.com/llvm/llvm-project/commit/4502187e2dde66d801d89f156dc47cc70509068f
DIFF: https://github.com/llvm/llvm-project/commit/4502187e2dde66d801d89f156dc47cc70509068f.diff
LOG: [clang][bytecode] Fix a crash with an invalid Descriptor (#224231)
It's neither a record nor an array.
Added:
Modified:
clang/lib/AST/ByteCode/EvaluationResult.cpp
clang/test/AST/ByteCode/invalid.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/EvaluationResult.cpp b/clang/lib/AST/ByteCode/EvaluationResult.cpp
index 5d232c5414e04..09b1eb822b13e 100644
--- a/clang/lib/AST/ByteCode/EvaluationResult.cpp
+++ b/clang/lib/AST/ByteCode/EvaluationResult.cpp
@@ -55,8 +55,7 @@ static bool CheckArrayInitialized(InterpState &S, SourceLocation Loc,
PtrView ElemPtr = BasePtr.atIndex(I).narrow();
Result &= CheckFieldsInitialized(S, Loc, ElemPtr, R);
}
- } else {
- assert(ElemDesc->isArray());
+ } else if (ElemDesc->isArray()) {
for (size_t I = 0; I != NumElems; ++I) {
PtrView ElemPtr = BasePtr.atIndex(I).narrow();
Result &= CheckArrayInitialized(S, Loc, ElemPtr);
diff --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp
index 2e822e0b56d91..3dd2dc91df9c1 100644
--- a/clang/test/AST/ByteCode/invalid.cpp
+++ b/clang/test/AST/ByteCode/invalid.cpp
@@ -267,3 +267,18 @@ namespace SubPtrResultIs1 {
struct C : A, B {};
unsigned char x = ((char **)(B *)(C *)0x1000) - (char *)0x1000; // both-error {{not pointers to compatible types}}
}
+
+namespace NonRecordNonArrayDesc {
+
+ struct S { // both-note {{definition of 'NonRecordNonArrayDesc::S' is not complete until the closing '}'}}
+ const S(foo[42]) : bar{}; // both-error {{use of undeclared identifier 'bar'}} \
+ // both-error {{field has incomplete type 'const S'}}
+ };
+
+ struct F {
+ _Atomic(S) a;
+ constexpr F(int i) {};
+ };
+
+ F foo(42);
+}
More information about the cfe-commits
mailing list