Skip to content

Commit 7b0d910

Browse files
authored
[clang][bytecode] Check for dummy pointers in CopyArray op (#158543)
They can't be written to or read from. Fixes #158535
1 parent 1c21d5c commit 7b0d910

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clang/lib/AST/ByteCode/Interp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,6 +3156,9 @@ inline bool CopyArray(InterpState &S, CodePtr OpPC, uint32_t SrcIndex,
31563156
const auto &SrcPtr = S.Stk.pop<Pointer>();
31573157
const auto &DestPtr = S.Stk.peek<Pointer>();
31583158

3159+
if (SrcPtr.isDummy() || DestPtr.isDummy())
3160+
return false;
3161+
31593162
for (uint32_t I = 0; I != Size; ++I) {
31603163
const Pointer &SP = SrcPtr.atIndex(SrcIndex + I);
31613164

clang/test/AST/ByteCode/vectors.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,15 @@ namespace Assign {
168168
}
169169
static_assert(invalid()); // both-error {{not an integral constant expression}}
170170
}
171+
172+
namespace CopyArrayDummy {
173+
struct S {
174+
long a, b, c, d;
175+
};
176+
typedef long T __attribute__((vector_size(4 * sizeof(long))));
177+
178+
void foo(void) {
179+
struct S s;
180+
*(T *)&s = (T){0, 1, 2, 3};
181+
}
182+
}

0 commit comments

Comments
 (0)