https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/243392
That should never happen. >From ebbdd1d9ad3c6a1b026b5631e0677fbdd6309d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Tue, 17 Nov 2026 09:50:46 +0100 Subject: [PATCH] [clang][bytecode] Disallow deref() on array roots --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 4 ++-- clang/lib/AST/ByteCode/Pointer.h | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index e35e198da0dcbe..ff7a8a7c098276 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -7098,8 +7098,8 @@ static void zeroAll(PtrView Dest) { if (Desc->isPrimitiveArray()) { for (unsigned I = 0, N = Desc->getNumElems(); I != N; ++I) { TYPE_SWITCH(Desc->getPrimType(), { - Dest.deref<T>().~T(); - new (&Dest.deref<T>()) T(); + Dest.elem<T>(I).~T(); + new (&Dest.elem<T>(I)) T(); }); } return; diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h index f1dcc5637455d0..fa864bb91d8502 100644 --- a/clang/lib/AST/ByteCode/Pointer.h +++ b/clang/lib/AST/ByteCode/Pointer.h @@ -246,11 +246,7 @@ struct PtrView { template <typename T> T &deref() const { assert(isLive() && "Invalid pointer"); assert(Pointee); - - if (isArrayRoot()) - return *reinterpret_cast<T *>(Pointee->data() + Base + - sizeof(InitMapPtr)); - + assert(!isArrayRoot()); return *reinterpret_cast<T *>(Pointee->data() + Offset); } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
