[clang] 3503a1c - [clang][bytecode] Not all bases compare equal (#204052)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 16 01:03:12 PDT 2026
Author: Timm Baeder
Date: 2026-06-16T10:03:07+02:00
New Revision: 3503a1c868f27a925ec2714bc18174eb73303505
URL: https://github.com/llvm/llvm-project/commit/3503a1c868f27a925ec2714bc18174eb73303505
DIFF: https://github.com/llvm/llvm-project/commit/3503a1c868f27a925ec2714bc18174eb73303505.diff
LOG: [clang][bytecode] Not all bases compare equal (#204052)
Add the base class offset so they don't all compare equal.
Added:
Modified:
clang/lib/AST/ByteCode/Pointer.cpp
clang/test/AST/ByteCode/cxx11.cpp
Removed:
################################################################################
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
diff erent 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
diff erent 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, "");
}
More information about the cfe-commits
mailing list