File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -5836,6 +5836,8 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
58365836 return false ;
58375837
58385838 if (R->isUnion () && Ctor->isCopyOrMoveConstructor ()) {
5839+ if (R->getNumFields () == 0 )
5840+ return this ->emitRetVoid (Ctor);
58395841 // union copy and move ctors are special.
58405842 assert (cast<CompoundStmt>(Ctor->getBody ())->body_empty ());
58415843 if (!this ->emitThis (Ctor))
Original file line number Diff line number Diff line change @@ -600,6 +600,18 @@ namespace MoveOrAssignOp {
600600 }
601601 static_assert (foo());
602602}
603+
604+ namespace CopyEmptyUnion {
605+ struct A {
606+ union {}; // both-warning {{declaration does not declare anything}}
607+ };
608+ constexpr int foo () {
609+ A a;
610+ A a2 = a;
611+ return 1 ;
612+ }
613+ static_assert (foo() == 1 );
614+ }
603615#endif
604616
605617namespace AddressComparison {
You can’t perform that action at this time.
0 commit comments