<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122937>122937</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
llvm/lib/CodeGen/LiveRangeUtils.h:40: Iterators applied to wrong data structure ?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:codegen,
code-quality
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dcb314
</td>
</tr>
</table>
<pre>
Static analyser cppcheck says:
llvm/lib/CodeGen/LiveRangeUtils.h:40:6: error: Same iterator is used with different containers 'LR' and 'LR.segments'. [iterators1]
Source code is
typename LiveRangeT::iterator J = LR.begin(), E = LR.end();
// ...
LR.segments.erase(J, E);
So J and E are iterators for LR, but get used on LR.segments.
I am surprised this compiles.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUUk1v2zAM_TX0hajhUP48-JAm9dCip3b7AbLE2Nocy5PkFvn3g5w23Y4DfDAJ6vG9xye9N8PM3EJxD8UxkWsYrWu16sUuT3qrL-1rkMEolLOcLp4dqmVRI6tf6OXFg9hDFr9pejsDdZPpgbqD1fyNZ6Du2bzxi5wH_hHM5NMRxD7PQOxLEHtk56yLP6_yzGgCOxmsQ-Nx9azx3YQRtTmd2PEcUNk5SDOz8whUPb8AVShnfS1Sz8OZ5-CBqhShuP9E8zsojleKr3Z1ilFZzWj8tYcYLgvPcf-N6vcoSuxvfJ4QxBGfX9KeBzMD1UAN0AEfPvs864-uuN8wgTqgDtM03cq_6KXspGeg-mlDuL3Z6OHTJugBpfuyw-PJOoxyD9ivAQcOV3vs_A_wFeQR5Rn96hZn4kwYjUdlz4uZ-HMk0a3QjWhkwu2uEmVd5UVTJ2N7KpUutZaiZtWUfZFpappK1VIoOjWCE9NSRkW22-W7KmuKPK0pP2WSdV1zQ2VTQp7xWZopjWlIrRsS4_3K7Y6oEVUyyZ4nv0WNaAuM2MdrDDEqBHQAoljf_V7lZMIlNotj4to4e9evg4c8m4wP_mtBMGHi9j_Th483c-WyTCY6ZfHd2XlALYNEH9yqwuoYQXTJ6qZ2DGHZ0r6ddjBhXPtU2W3rx_JIcnH2J6sA1G3KPVD3If6tpT8BAAD__8EOEx8">