https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/200774
That shouldn't happen and the isDummy() check wasn't enough. >From 3b07a174d38b787aa53d8d3a7bc991aa6c35eae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Mon, 1 Jun 2026 12:28:25 +0200 Subject: [PATCH] [clang][bytecode] Don't deref() non-dereferencable pointers That shouldn't happen and the isDummy() check wasn't enough. --- clang/lib/AST/ByteCode/Interp.h | 2 +- clang/test/AST/ByteCode/invalid.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 86795e13a14ff..fa77e19afce66 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -2599,7 +2599,7 @@ bool SubOffset(InterpState &S, CodePtr OpPC) { template <ArithOp Op> static inline bool IncDecPtrHelper(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { - if (Ptr.isDummy()) + if (!Ptr.isDereferencable()) return false; using OneT = Char<false>; diff --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp index 9513645a74794..fb209d353c4a1 100644 --- a/clang/test/AST/ByteCode/invalid.cpp +++ b/clang/test/AST/ByteCode/invalid.cpp @@ -198,3 +198,14 @@ namespace InvalidUnaryOperator { ; } } + +namespace IncNonDereferencable { + struct S {}; + + void foo() { + S *s = (foo *)malloc(sizeof(*s)); // both-error {{expected expression}} + S *&sref = s; + for (int i = 0; i < 2; sref++) + ; + } +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
