Skip to content

Commit 875d24c

Browse files
committed
[ELF] Avoid list initialization with incomplete unique_ptr<OutputSection> member to work around clang < 16
Commit 5b1b6a6 introduced the following issue for older clang with libstdc++ ``` In file included from /home/ray/llvm/lld/ELF/EhFrame.cpp:18: In file included from /home/ray/llvm/lld/ELF/EhFrame.h:12: In file included from /home/ray/llvm/lld/include/lld/Common/LLVM.h:21: In file included from /home/ray/llvm/llvm/include/llvm/Support/Casting.h:20: In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/memory:78: /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:91:16: error: invalid application of 'sizeof' to an incomplete type 'lld::elf::OutputSection' static_assert(sizeof(_Tp)>0, ^~~~~~~~~~~ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:398:4: note: in instantiation of member function 'std::default_delete<lld::elf::OutputSection>::operator()' requested here get_deleter()(std::move(__ptr)); ^ /home/ray/llvm/lld/ELF/Config.h:574:19: note: in instantiation of member function 'std::unique_ptr<lld::elf::OutputSection>::~unique_ptr' requested here OutSections out{}; ^ ```
1 parent 2d7ec7f commit 875d24c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lld/ELF/Config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,11 @@ struct Ctx : CommonLinkerContext {
567567
struct OutSections {
568568
std::unique_ptr<OutputSection> elfHeader;
569569
std::unique_ptr<OutputSection> programHeaders;
570-
OutputSection *preinitArray;
571-
OutputSection *initArray;
572-
OutputSection *finiArray;
570+
OutputSection *preinitArray = nullptr;
571+
OutputSection *initArray = nullptr;
572+
OutputSection *finiArray = nullptr;
573573
};
574-
OutSections out{};
574+
OutSections out;
575575
SmallVector<OutputSection *, 0> outputSections;
576576
std::vector<Partition> partitions;
577577

0 commit comments

Comments
 (0)