<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69048>69048</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang/lib/Serialization/ASTWriter.cpp:1096: 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/Serialization/ASTWriter.cpp:1096:18: style: Array index 'Pos' is used before limits check. [arrayIndexThenCheck]
Source code is
for (; Filename[Pos] && Pos < BaseDir.size(); ++Pos)
Suggest move sanity check to before use.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycUs1u4zwMfBr6QtSwKf8efEgaGPhuBVLgO8sy42hXsQxRzm769Au7Lba97kUUJI5mRhwtYqeZuYPyCOUp0Wu8-tCNZlB5kQx-fHTnqKM1qGftHsIBzbKYK5ufKPohoA6QnSD7WI3T8wTUOzsA9WcOVjv7pqP1M1B_OL_-H2zkkJplAXXIs7baSgPqgBIfjrfNIQT9QDuP_BuB6hcvQDVawVV4xIEvPjA6e7NRcBeSIpRHvaH-20CvV56ft3MoT1-1nf0aDKPxI6OVrzeIFx8QqAF1xN46nvWNoTxu1OUJgSqgCl-8IKhnPGrhkw2p2DfeMNRuMKAj0I6g9hvrOk0sEW_-zih6tvHxrhqj_zSzCqfv3cnYqbFVrU64y6u2ppqapkqu3cXUpmq4qi5jXXA91DResqrIMt3UA42U2I4yUnmWF1lT5FSllDekFCtW5XipCoIi45u2LnXufkt9mBIrsnJXtVnRJE4P7GRPAdHHFGkLROi2_qdhnQSKzFmJ8veFaKPj7p-G_v0v7Iy_gp8nXJw2jKD6ZA2uu8a47BGjHqifbLyuQ2r8bSNz98_ytAT_g00E6ndLAtTvrv4EAAD__6dH4vk">