Skip to content

-Wdangling-reference reported in llvm/lib/DebugInfo/PDB/Native/ #125544

@firewave

Description

@firewave
/home/user/CLionProjects/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp: In member function ‘virtual bool llvm::pdb::NativeSession::addressForRVA(uint32_t, uint32_t&, uint32_t&) const’:
/home/user/CLionProjects/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp:239:11: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  239 |     auto &Sec = Dbi->getSectionHeaders()[Section];
      |           ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp:239:49: note: the temporary was destroyed at the end of the full expression ‘llvm::pdb::DbiStream::getSectionHeaders() const().llvm::FixedStreamArray<llvm::object::coff_section>::operator[](Section)’
  239 |     auto &Sec = Dbi->getSectionHeaders()[Section];
      |                                                 ^
[ 51%] Building CXX object lib/DebugInfo/PDB/CMakeFiles/LLVMDebugInfoPDB.dir/Native/PublicsStream.cpp.o
/home/user/CLionProjects/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp: In member function ‘uint32_t llvm::pdb::NativeSession::getRVAFromSectOffset(uint32_t, uint32_t) const’:
/home/user/CLionProjects/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp:392:9: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  392 |   auto &Sec = Dbi->getSectionHeaders()[Section - 1];
      |         ^~~
/home/user/CLionProjects/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp:392:51: note: the temporary was destroyed at the end of the full expression ‘llvm::pdb::DbiStream::getSectionHeaders() const().llvm::FixedStreamArray<llvm::object::coff_section>::operator[]((Section - 1))’
  392 |   auto &Sec = Dbi->getSectionHeaders()[Section - 1];
      |                                                   ^

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions