diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 943cf18e6cf05..570d5f561c159 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1402,7 +1402,7 @@ void MergeInputSection::splitNonStrings(ArrayRef data, assert((size % entSize) == 0); const bool live = !(flags & SHF_ALLOC) || !config->gcSections; - pieces.assign(size / entSize, SectionPiece(0, 0, false)); + pieces.resize_for_overwrite(size / entSize); for (size_t i = 0, j = 0; i != size; i += entSize, j++) pieces[j] = {i, (uint32_t)xxHash64(data.slice(i, entSize)), live}; } diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 0b80125141390..adfc45ece9bcd 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -242,6 +242,7 @@ class InputSectionBase : public SectionBase { // have to be as compact as possible, which is why we don't store the size (can // be found by looking at the next one). struct SectionPiece { + SectionPiece() = default; SectionPiece(size_t off, uint32_t hash, bool live) : inputOff(off), live(live), hash(hash >> 1) {}