llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> It's fine if they are uninitialized. --- Full diff: https://github.com/llvm/llvm-project/pull/191783.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.h (+4-2) - (modified) clang/test/AST/ByteCode/cxx11.cpp (+11-1) ``````````diff diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 2ba223010d4ad..39d30edd5cf02 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 91c828abd87a9..668228e2dc166 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]; `````````` </details> https://github.com/llvm/llvm-project/pull/191783 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
