https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/204052
Add the base class offset so they don't all compare equal. >From 72fa224fc08d9944ad241a9c5bfa1298e1e1cd29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Tue, 16 Jun 2026 06:07:40 +0200 Subject: [PATCH] [clang][bytecode] Not all bases compare equal Add the base class offset so they don't all compare equal. --- clang/lib/AST/ByteCode/Pointer.cpp | 3 +-- clang/test/AST/ByteCode/cxx11.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 9e91b1461fda9..995a4495f1438 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -392,8 +392,7 @@ Pointer::computeOffsetForComparison(const ASTContext &ASTCtx) const { } if (P.isBaseClass()) { - if (P.getRecord()->getNumVirtualBases() > 0) - Result += P.getInlineDesc()->Offset; + Result += P.getInlineDesc()->Offset - sizeof(InlineDescriptor); P = P.getBase(); continue; } diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp index 5d217f0bdd6cc..ffe2f3c67c511 100644 --- a/clang/test/AST/ByteCode/cxx11.cpp +++ b/clang/test/AST/ByteCode/cxx11.cpp @@ -469,8 +469,8 @@ namespace SubobjectCompare { constexpr Z z{}; static_assert(&z.x < &z.y, ""); // both-error {{not an integral constant expression}} \ // both-note {{comparison of addresses of subobjects of different base classes has unspecified value}} - static_assert(&z.x != &z.y, ""); // expected-error {{failed}} FIXME + static_assert(&z.x != &z.y, ""); static_assert((void*)(X*)&z < (void*)(Y*)&z, ""); // both-error {{not an integral constant expression}} \ // both-note {{comparison of addresses of subobjects of different base classes has unspecified value}} - static_assert((void*)(X*)&z != (void*)(Y*)&z, ""); // expected-error {{failed}} FIXME + static_assert((void*)(X*)&z != (void*)(Y*)&z, ""); } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
