Issue 125544
Summary `-Wdangling-reference` reported in `llvm/lib/DebugInfo/PDB/Native/`
Labels code-quality, debuginfo
Assignees
Reporter 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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to