[clang] [clang][bytecode] Check for non-block pointers in CopyArray (PR #175710)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 12 22:03:24 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
Fixes https://github.com/llvm/llvm-project/issues/175674
---
Full diff: https://github.com/llvm/llvm-project/pull/175710.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/Interp.h (+3)
- (modified) clang/test/AST/ByteCode/c.c (+6)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 7ccd690d22fb7..7700b6bc5f2dd 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -3199,6 +3199,9 @@ inline bool CopyArray(InterpState &S, CodePtr OpPC, uint32_t SrcIndex,
if (SrcPtr.isDummy() || DestPtr.isDummy())
return false;
+ if (!SrcPtr.isBlockPointer() || !DestPtr.isBlockPointer())
+ return false;
+
for (uint32_t I = 0; I != Size; ++I) {
const Pointer &SP = SrcPtr.atIndex(SrcIndex + I);
diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index 0d3d97b5eeab2..22ec0ea355132 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -405,3 +405,9 @@ typedef struct S64 {
_Static_assert((((I64){}, 1)), ""); // all-warning {{left operand of comma operator has no effect}} \
// pedantic-warning {{use of an empty initializer is a C23 extension}} \
// pedantic-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}
+
+#define V(N) __attribute__((vector_size(N)))
+#define C2 (VC2){0, 1}
+char m();
+typedef V(2) char VC2;
+void CopyArrayToFnPtr() { *(VC2 *)m = C2; }
``````````
</details>
https://github.com/llvm/llvm-project/pull/175710
More information about the cfe-commits
mailing list