<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/125544>125544</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-Wdangling-reference` reported in `llvm/lib/DebugInfo/PDB/Native/`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
code-quality,
debuginfo
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```
/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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkVk9v47YT_TTjy8CGNLQc6aCD_0S_X4CkDTZAurcFJY5kbmXRJakkvuxnLyjLcRa7KdICuylQwrCGFDUE33vzMNI53XTMOSQrSDYT2futsXmtLT_KB56URh1yWETjL1oCFVuzY6Cid2yBivW1Nt2tNZ-58g6oaNuH3XR_nI_T8NAlULHhsm-uutoAFbebFVDxi_T6gZ-DO3ZOm25W7fcglnjV4Y53JVus-67y2nQIlwRpBFn6oK3vZYulMS0Op4gliOVelcfgq4THJamUZecKYz_cL4HSXnde0CcPtMZzvPhmmmFlOudPR2ch289FgkQ4NI4DKI_SdrprQrg3zumyPaCSXdPqrkHLNVvuKkZvUKLn3d5YaQ8IyWr622nb9HkbJBuIlogkMoSLNYYhe28QaHHHFYLY4KbUUxCXDfs7Hkj4P0vF1gGlQBkkq3E55BKrIV0Yp3TjLLn88uVdUJuHP-yM5_D0W36ByqN0qNh5aw6sUPrhNXcKTT2Edd-2yE97e8x7Vt93BLcp9Z23LMf1V-AapTTEs3OWQj-xOn6-tFYeQKzPL005gDHElanrT24EXFyOG_ZspTf2WMRA6YkRys6i_Sk0v21AchmkkKwwiYESSDa46nWrgoLXHz_i8cL4GunrG_k7F7rloJfr6_ub5y23m9VMaftSGLd92erKHbENwpiZf5ONnYzmjRbWsP9wvyys2QU2fq1rx_5VJ3t_3xIZgVhmP8y2REajAP-pmnGK8V8o-j1s6whaEv_3bOvsXAMtlH1jYD-c8L9tYi97o2h5hXKHvQuahkXUVBUCpf9brwOE8XxGsxgponmUxeEbNB3eyO6ztAavddc_zSYqFyoTmZxwHl-IdBHNE3Ex2eapiqKqTjKhauKaOI5kpCqxkHGaykUmJzqniJKIIhFfzCm-mKlSZbKK0zqu6jSpEphHvJO6HeibGdtMtHM95zElyXw-aWXJrRv6QKLKKJ7-0ctW-wMQAa2BSAUZ60HGFHpFmw-iL_vGwTxqtfPunNtr33LoHL9bvosILe-N9axQdwGqtxYMLKJJb9t86_3eBRlRAVQ02m_7claZ3Yva-7oih8uGSh3v-5DTnwEAAP__HLBc8g">