File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -5604,6 +5604,22 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
56045604
56055605 if (!emitFieldInitializer (NestedField, NestedFieldOffset, InitExpr))
56065606 return false ;
5607+
5608+ // Mark all chain links as initialized.
5609+ unsigned InitFieldOffset = 0 ;
5610+ for (const NamedDecl *ND : IFD->chain ().drop_back ()) {
5611+ const auto *FD = cast<FieldDecl>(ND);
5612+ const Record *FieldRecord = this ->P .getOrCreateRecord (FD->getParent ());
5613+ assert (FieldRecord);
5614+ NestedField = FieldRecord->getField (FD);
5615+ InitFieldOffset += NestedField->Offset ;
5616+ assert (NestedField);
5617+ if (!this ->emitGetPtrThisField (InitFieldOffset, InitExpr))
5618+ return false ;
5619+ if (!this ->emitFinishInitPop (InitExpr))
5620+ return false ;
5621+ }
5622+
56075623 } else {
56085624 assert (Init->isDelegatingInitializer ());
56095625 if (!this ->emitThis (InitExpr))
Original file line number Diff line number Diff line change @@ -463,4 +463,26 @@ namespace MoveAssign {
463463 }
464464 static_assert (f()== 12 );
465465}
466+
467+ namespace IFD {
468+ template <class T >
469+ struct Optional {
470+ struct {
471+ union {
472+ char null_state;
473+ T val;
474+ };
475+ };
476+ constexpr Optional () : null_state(){}
477+ };
478+
479+ constexpr bool test ()
480+ {
481+ Optional<int > opt{};
482+ Optional<int > opt2{};
483+ opt = opt2;
484+ return true ;
485+ }
486+ static_assert (test());
487+ }
466488#endif
You can’t perform that action at this time.
0 commit comments