<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69047>69047</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang/lib/Format/WhitespaceManager.cpp:1426:sanity check in wrong place ?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dcb314
</td>
</tr>
</table>
<pre>
Static analyser cppcheck says:
clang/lib/Format/WhitespaceManager.cpp:1426:23: style: Array index 'j' is used before limits check. [arrayIndexThenCheck]
Source code is
while (Changes[j].Tok != NextNonComment && j < End)
++j;
Suggest move sanity check to before use.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyckk1vvSgUxj_NcXNSowf06sLFfRmTWUw3bTJrxFPlFsEAtr3ffuJtm2m3fxZA4Lw8D_xUjGZyzB1UJ6gumdrS7EM36kGUMhv8eOuekkpGo3LK3iIH1OuqZ9avGNUtgjhCcYHia9ZWuQmot2YA6nsfFpWA-n9nkziuSvM_yqmJQ67XFcSxlFSDOJIAccSYbpb3zTEEdUPjRv5AoMMV6IAm4hZ5xIFffGC0ZjEp4l1HjlCd1J7z957yPLM77-dQXX5Ke_Jb0Izaj4wm_rzBz_E-G8sI1Jxn5SaOUJ2uUF3yZ_-KQCWICz7yR3r07uyXhV1CoBqoxiuCOONfbgRqvyoCnYBOVxCnXxK2aeKYcPFvjFE5k26fFjD5b2db5PwzOhs7MbaiVRl3Zd0e6ECHss7mrqlKIYuqLQqSQhdCNrJWsn1RPFbUyjIzHRUkyqKURSMaUefcsGqprIVg2cqmAVnwoozNrX1bch-mzMS4cVe3hTxkVg1s450Ioq8fpR2O0O3xD8M2RZCFNTHF_yskkyx3fwbAr7cwDt-DdxOuVmlGEH22BdvNKa133KgH6ieT5m3ItV_2Zvbte3lYg7-y3nveLUWg_u7qvwAAAP__kL7kwg">