https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/191783
It's fine if they are uninitialized. >From 5e7ce6c719cfb07107932bd146ec149ab618bb38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Mon, 13 Apr 2026 11:48:27 +0200 Subject: [PATCH] [clang][bytecode] Don't check anonymous union in memcpy op --- clang/lib/AST/ByteCode/Interp.h | 6 ++++-- clang/test/AST/ByteCode/cxx11.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 2ba223010d4ad3..39d30edd5cf02d 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -2428,8 +2428,10 @@ inline bool Memcpy(InterpState &S, CodePtr OpPC) { const Pointer &Src = S.Stk.pop<Pointer>(); Pointer &Dest = S.Stk.peek<Pointer>(); - if (!CheckLoad(S, OpPC, Src)) - return false; + if ((!Src.getRecord() || !Src.getRecord()->isAnonymousUnion())) { + if (!CheckLoad(S, OpPC, Src)) + return false; + } return DoMemcpy(S, OpPC, Src, Dest); } diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp index 91c828abd87a9e..668228e2dc1669 100644 --- a/clang/test/AST/ByteCode/cxx11.cpp +++ b/clang/test/AST/ByteCode/cxx11.cpp @@ -345,6 +345,16 @@ namespace ReadMutableInCopyCtor { // both-note {{in call to 'G(g1)'}} } +namespace ReadAnonUnionInCopyCtor { + struct G { + struct X {}; + union U { X a; }; + union {X a; }; + }; + constexpr G g1 = {}; + constexpr G g2 = g1; +} + namespace GH150709 { struct C { }; struct D : C { @@ -353,7 +363,7 @@ namespace GH150709 { struct E : C { }; struct F : D { }; struct G : E { }; - + constexpr C c1, c2[2]; constexpr D d1, d2[2]; constexpr E e1, e2[2]; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
