[clang] [clang][bytecode] Fix comparing pointers to union members (PR #154342)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 22 21:22:49 PDT 2025


================
@@ -966,3 +966,15 @@ namespace AddressComparison {
   static_assert(&U2.a[0] != &U2.b[1]);
   static_assert(&U2.a[0] == &U2.b[1]); // both-error {{failed}}
 }
+
+#if __cplusplus >= 202002L
+namespace UnionMemberOnePastEnd {
+  constexpr bool b() {
+    union  {
+      int p;
+    };
+    return &p == (&p + 1);
----------------
shafik wrote:

Do we have a test that shows it fails for `return &p == (&p + 2);`?

https://github.com/llvm/llvm-project/pull/154342


More information about the cfe-commits mailing list