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

They can't be written to or read from.

Fixes #158535

>From 614a2f42bab39fd0b7d40172f328aa8596d617fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com>
Date: Mon, 15 Sep 2025 07:34:21 +0200
Subject: [PATCH] [clang][bytecode] Check for dummy pointers in CopyArray op

They can't be written to or read from.

Fixes #158535
---
 clang/lib/AST/ByteCode/Interp.h     |  3 +++
 clang/test/AST/ByteCode/vectors.cpp | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 9a7bd03bea077..d8362ee3176a0 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -3156,6 +3156,9 @@ inline bool CopyArray(InterpState &S, CodePtr OpPC, 
uint32_t SrcIndex,
   const auto &SrcPtr = S.Stk.pop<Pointer>();
   const auto &DestPtr = S.Stk.peek<Pointer>();
 
+  if (SrcPtr.isDummy() || DestPtr.isDummy())
+    return false;
+
   for (uint32_t I = 0; I != Size; ++I) {
     const Pointer &SP = SrcPtr.atIndex(SrcIndex + I);
 
diff --git a/clang/test/AST/ByteCode/vectors.cpp 
b/clang/test/AST/ByteCode/vectors.cpp
index 91fec8f86f613..2eb615e906cf5 100644
--- a/clang/test/AST/ByteCode/vectors.cpp
+++ b/clang/test/AST/ByteCode/vectors.cpp
@@ -168,3 +168,15 @@ namespace Assign {
   }
   static_assert(invalid()); // both-error {{not an integral constant 
expression}}
 }
+
+namespace CopyArrayDummy {
+  struct S {
+    long a, b, c, d;
+  };
+  typedef long T __attribute__((vector_size(4 * sizeof(long))));
+
+  void foo(void) {
+    struct S s;
+    *(T *)&s = (T){0, 1, 2, 3};
+  }
+}

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to