https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/175710

Fixes https://github.com/llvm/llvm-project/issues/175674

>From d0f8ae3d9d27066cd1570a76a1c647f3daa8a7e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
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..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; }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to