[clang] [clang][bytecode] Fix isZero() assertion in OffsetHelper (PR #242271)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 13 03:53:35 PST 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/242271
zero pointers are possible and expected here, e.g. integer pointers with zero value.
>From 41826b2b19c1934abe800de9d2e6eb72f9cbad13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Fri, 13 Nov 2026 12:51:58 +0100
Subject: [PATCH] [clang][bytecode] Fix isZero() assertion in OffsetHelper
zero pointers are possible and expected here, e.g. integer pointers with
zero value.
---
clang/lib/AST/ByteCode/Interp.h | 4 +---
clang/test/Parser/cxx-ambig-paren-expr.cpp | 1 +
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 3b1df5fe7615e..18c2421a67231 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2504,9 +2504,6 @@ bool TrivialCopy(InterpState &S, CodePtr OpPC, bool Activate,
template <class T, ArithOp Op>
std::optional<Pointer> OffsetHelper(InterpState &S, CodePtr OpPC,
const T &Offset, const Pointer &Ptr) {
- if (S.getLangOpts().CPlusPlus)
- assert(!Ptr.isZero());
-
// This is much simpler for integral pointers, so handle them first.
if (Ptr.isIntegralPointer()) {
uint64_t V = Ptr.getIntegerRepresentation();
@@ -2549,6 +2546,7 @@ std::optional<Pointer> OffsetHelper(InterpState &S, CodePtr OpPC,
}
assert(Ptr.isBlockPointer());
+ assert(!Ptr.isZero());
PtrView P = Ptr.view();
// Arrays of unknown bounds cannot have pointers into them.
diff --git a/clang/test/Parser/cxx-ambig-paren-expr.cpp b/clang/test/Parser/cxx-ambig-paren-expr.cpp
index 160ce4c3bb72f..1985f3c96e0ed 100644
--- a/clang/test/Parser/cxx-ambig-paren-expr.cpp
+++ b/clang/test/Parser/cxx-ambig-paren-expr.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s -fexperimental-new-constant-interpreter
void f() {
typedef int T;
More information about the cfe-commits
mailing list