[clang] [clang][bytecode] Check for non-block pointers in CopyArray (PR #175710)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 12 22:19:02 PST 2026
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/175710
>From 5db8a39d4373b2aab138530312bcf183be05bbc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 13 Jan 2026 07:01:57 +0100
Subject: [PATCH] [clang][bytecode] Check for non-block pointers in CopyArray
Fixes https://github.com/llvm/llvm-project/issues/175674
---
clang/lib/AST/ByteCode/Interp.h | 3 +++
clang/test/AST/ByteCode/c.c | 6 ++++++
2 files changed, 9 insertions(+)
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..080d70aea8cba 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 func_(void);
+typedef V(2) char VC2;
+void CopyArrayToFnPtr(void) { *(VC2 *)func_ = C2; }
More information about the cfe-commits
mailing list