Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wdangling-reference warnings in llvm/lib/Object/ #125542

Open
firewave opened this issue Feb 3, 2025 · 1 comment
Open

-Wdangling-reference warnings in llvm/lib/Object/ #125542

firewave opened this issue Feb 3, 2025 · 1 comment

Comments

@firewave
Copy link

firewave commented Feb 3, 2025

/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp: In instantiation of ‘llvm::Expected<llvm::MapVector<const typename ELFT::Shdr*, const typename ELFT::Shdr*> > llvm::object::ELFFile<ELFT>::getSectionAndRelocations(std::function<llvm::Expected<bool>(const typename ELFT::Shdr&)>) const [with ELFT = llvm::object::ELFType<llvm::endianness::little, false>; typename ELFT::Shdr = llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, false> >]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:986:51:   required from here
  986 | template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF32LE>;
      |                                                   ^~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::little, false> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::little, false>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, false> > >](), 0)’
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp: In instantiation of ‘llvm::Expected<llvm::MapVector<const typename ELFT::Shdr*, const typename ELFT::Shdr*> > llvm::object::ELFFile<ELFT>::getSectionAndRelocations(std::function<llvm::Expected<bool>(const typename ELFT::Shdr&)>) const [with ELFT = llvm::object::ELFType<llvm::endianness::big, false>; typename ELFT::Shdr = llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, false> >]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:987:51:   required from here
  987 | template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF32BE>;
      |                                                   ^~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::big, false> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::big, false>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, false> > >](), 0)’
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp: In instantiation of ‘llvm::Expected<llvm::MapVector<const typename ELFT::Shdr*, const typename ELFT::Shdr*> > llvm::object::ELFFile<ELFT>::getSectionAndRelocations(std::function<llvm::Expected<bool>(const typename ELFT::Shdr&)>) const [with ELFT = llvm::object::ELFType<llvm::endianness::little, true>; typename ELFT::Shdr = llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, true> >]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:988:51:   required from here
  988 | template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF64LE>;
      |                                                   ^~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::little, true> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::little, true>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, true> > >](), 0)’
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~~~~
[ 43%] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
[ 43%] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/MachOObjectFile.cpp.o
[ 43%] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp: In instantiation of ‘llvm::Expected<llvm::MapVector<const typename ELFT::Shdr*, const typename ELFT::Shdr*> > llvm::object::ELFFile<ELFT>::getSectionAndRelocations(std::function<llvm::Expected<bool>(const typename ELFT::Shdr&)>) const [with ELFT = llvm::object::ELFType<llvm::endianness::big, true>; typename ELFT::Shdr = llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, true> >]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:989:51:   required from here
  989 | template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF64BE>;
      |                                                   ^~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELF.cpp:949:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::big, true> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::big, true>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, true> > >](), 0)’
  949 |   for (const Elf_Shdr &Sec : cantFail(this->sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~~~~
[ 43%] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/Minidump.cpp.o
[ 43%] Linking CXX static library ../../../libLLVMAArch64Desc.a
[ 43%] Built target LLVMAArch64Desc
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::VersionEntry> > readDynsymVersionsImpl(const llvm::object::ELFFile<ELFT>&, llvm::object::ELFObjectFileBase::elf_symbol_iterator_range) [with ELFT = llvm::object::ELFType<llvm::endianness::little, false>; llvm::object::ELFObjectFileBase::elf_symbol_iterator_range = llvm::iterator_range<llvm::object::elf_symbol_iterator>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1008:34:   required from here
 1008 |     return readDynsymVersionsImpl(Obj->getELFFile(), Symbols);
      |            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::little, false> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::little, false>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, false> > >](), 0)’
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~
[ 43%] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/ModuleSymbolTable.cpp.o
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::VersionEntry> > readDynsymVersionsImpl(const llvm::object::ELFFile<ELFT>&, llvm::object::ELFObjectFileBase::elf_symbol_iterator_range) [with ELFT = llvm::object::ELFType<llvm::endianness::big, false>; llvm::object::ELFObjectFileBase::elf_symbol_iterator_range = llvm::iterator_range<llvm::object::elf_symbol_iterator>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1010:34:   required from here
 1010 |     return readDynsymVersionsImpl(Obj->getELFFile(), Symbols);
      |            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::big, false> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::big, false>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, false> > >](), 0)’
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::VersionEntry> > readDynsymVersionsImpl(const llvm::object::ELFFile<ELFT>&, llvm::object::ELFObjectFileBase::elf_symbol_iterator_range) [with ELFT = llvm::object::ELFType<llvm::endianness::little, true>; llvm::object::ELFObjectFileBase::elf_symbol_iterator_range = llvm::iterator_range<llvm::object::elf_symbol_iterator>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1012:34:   required from here
 1012 |     return readDynsymVersionsImpl(Obj->getELFFile(), Symbols);
      |            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::little, true> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::little, true>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, true> > >](), 0)’
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::VersionEntry> > readDynsymVersionsImpl(const llvm::object::ELFFile<ELFT>&, llvm::object::ELFObjectFileBase::elf_symbol_iterator_range) [with ELFT = llvm::object::ELFType<llvm::endianness::big, true>; llvm::object::ELFObjectFileBase::elf_symbol_iterator_range = llvm::iterator_range<llvm::object::elf_symbol_iterator>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1013:32:   required from here
 1013 |   return readDynsymVersionsImpl(cast<ELF64BEObjectFile>(this)->getELFFile(),
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1014 |                                 Symbols);
      |                                 ~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:3: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |   ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:957:38: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::big, true> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::big, true>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, true> > >](), 0)’
  957 |   for (const Elf_Shdr &Sec : cantFail(EF.sections())) {
      |                              ~~~~~~~~^~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::BBAddrMap> > readBBAddrMapImpl(const llvm::object::ELFFile<ELFT>&, std::optional<unsigned int>, std::vector<llvm::object::PGOAnalysisMap>*) [with ELFT = llvm::object::ELFType<llvm::endianness::little, false>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1021:29:   required from here
 1021 |     return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses);
      |            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:15: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  901 |   const auto &Sections = cantFail(EF.sections());
      |               ^~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:34: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::little, false> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::little, false>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, false> > >](), 0)’
  901 |   const auto &Sections = cantFail(EF.sections());
      |                          ~~~~~~~~^~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::BBAddrMap> > readBBAddrMapImpl(const llvm::object::ELFFile<ELFT>&, std::optional<unsigned int>, std::vector<llvm::object::PGOAnalysisMap>*) [with ELFT = llvm::object::ELFType<llvm::endianness::little, true>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1023:29:   required from here
 1023 |     return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses);
      |            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:15: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  901 |   const auto &Sections = cantFail(EF.sections());
      |               ^~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:34: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::little, true> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::little, true>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::little, true> > >](), 0)’
  901 |   const auto &Sections = cantFail(EF.sections());
      |                          ~~~~~~~~^~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::BBAddrMap> > readBBAddrMapImpl(const llvm::object::ELFFile<ELFT>&, std::optional<unsigned int>, std::vector<llvm::object::PGOAnalysisMap>*) [with ELFT = llvm::object::ELFType<llvm::endianness::big, false>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1025:29:   required from here
 1025 |     return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses);
      |            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:15: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  901 |   const auto &Sections = cantFail(EF.sections());
      |               ^~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:34: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::big, false> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::big, false>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, false> > >](), 0)’
  901 |   const auto &Sections = cantFail(EF.sections());
      |                          ~~~~~~~~^~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp: In instantiation of ‘llvm::Expected<std::vector<llvm::object::BBAddrMap> > readBBAddrMapImpl(const llvm::object::ELFFile<ELFT>&, std::optional<unsigned int>, std::vector<llvm::object::PGOAnalysisMap>*) [with ELFT = llvm::object::ELFType<llvm::endianness::big, true>]’:
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:1026:27:   required from here
 1026 |   return readBBAddrMapImpl(cast<ELF64BEObjectFile>(this)->getELFFile(),
      |          ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1027 |                            TextSectionIndex, PGOAnalyses);
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:15: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  901 |   const auto &Sections = cantFail(EF.sections());
      |               ^~~~~~~~
/home/user/CLionProjects/llvm-project/llvm/lib/Object/ELFObjectFile.cpp:901:34: note: the temporary was destroyed at the end of the full expression ‘llvm::cantFail<ArrayRef<object::Elf_Shdr_Impl<object::ELFType<llvm::endianness::big, true> > > >(llvm::object::ELFFile<ELFT>::sections() const [with ELFT = llvm::object::ELFType<llvm::endianness::big, true>; typename ELFT::ShdrRange = llvm::ArrayRef<llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::endianness::big, true> > >](), 0)’
  901 |   const auto &Sections = cantFail(EF.sections());
      |                          ~~~~~~~~^~~~~~~~~~~~~~~

I am using gcc (GCC) 14.2.1 20240910 on Manjaro Linux.

@firewave
Copy link
Author

firewave commented Feb 3, 2025

There are also lots of these in llvm/tools/llvm-readobj/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant