Author: Timm Baeder Date: 2026-11-13T15:48:17+01:00 New Revision: 3f4d4496b63894539837fd3f636259e7c3ab20d2
URL: https://github.com/llvm/llvm-project/commit/3f4d4496b63894539837fd3f636259e7c3ab20d2 DIFF: https://github.com/llvm/llvm-project/commit/3f4d4496b63894539837fd3f636259e7c3ab20d2.diff LOG: [clang][bytecode] Fix isZero() assertion in OffsetHelper (#242271) zero pointers are possible and expected here, e.g. integer pointers with zero value. Added: Modified: clang/lib/AST/ByteCode/Interp.h clang/test/Parser/cxx-ambig-paren-expr.cpp Removed: ################################################################################ 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; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
