Index: clang/lib/AST/RecordLayoutBuilder.cpp =================================================================== --- clang/lib/AST/RecordLayoutBuilder.cpp +++ clang/lib/AST/RecordLayoutBuilder.cpp @@ -2923,11 +2923,18 @@ ElementInfo Info = getAdjustedElementInfo(FD); Alignment = std::max(Alignment, Info.Alignment); CharUnits FieldOffset; + auto *FieldClass = FD->getType()->getAsCXXRecordDecl(); + bool PotentiallyOverlapping = + FD->hasAttr() && FieldClass; + bool IsOverlappingEmptyField = + PotentiallyOverlapping && FieldClass->isEmpty(); if (UseExternalLayout) FieldOffset = Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD)); - else if (IsUnion) + else if (IsUnion || IsOverlappingEmptyField) + { FieldOffset = CharUnits::Zero(); + } else FieldOffset = Size.alignTo(Info.Alignment); placeFieldAtOffset(FieldOffset);