<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92626>92626</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang -Warray-bounds gives a false positive when there are compilation errors
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fahadnayyar
</td>
</tr>
</table>
<pre>
```
#define foo(i, arr) ((i > 0) ? arr[i-1] : 0)
int main(void) {
does_not_exist();
int arr[] = {1, 2, 3};
foo(0, arr);
}
```
clang thinks that when `i` is 0, we can access an out of bounds index through `arr[i-1]` even though we guard that access with the check `(i > 0)`.
https://godbolt.org/z/hzfn81ds3
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsktGOozoMhp_G3FitQigULriYnh5eYS9HJjEkOzSpktBO5-lXQFfTXa2EjBLH32__CcVoR8fcQnmC8pzRnIwP7UCGtKPHg0LWe_1oQZxBvEElnt-2lIXmwTrGwXuQtQX5H1IIIBsEWS87CMX_KNaNoltz5cnucijPCMXbmnmy1mhdwgtZB7K-eavXuuPp94lGe47vzqd3_rQxrRINFKdXAohmgWxKm8x5YeRLb3IJBRzPL0XN1rv47v07eTz_e-41qonciMlY9xExGUp4N-wQKmGhEmgjrsw7oyKHpBTHiOTQzwn9gL2fnY5oneZPTCb4eTRL8atHC4dv7DCZNX1nHGcKepN7Iu82GUyGURlWHwviD-OhEvvXtk1K1wjFG8gOZDd63fsp7X0YQXZfIDvzNbg617HIdFvopmgo4zY_5mXT1OJwzEyr6SBkMXBf5IqUkKWoD_VAJeUD54eiymwrhTyIMq-FFEd53A-NVqquZFn1uh_yHA6CL2Sn_TTdLot2ZmOcuW1kJatsop6nuL5IKRVIuTzM0C5nd_08RjiIycYUv6uTTRO324XsflAI9Ng9_R3tjSMSDjRFxquPNtkbb1eVDAdGCozKX652omS9Qw7Bh5jNYWr_8somM_d75S8gu0X7-dtdg__JKoHs1jEiyG6d5FcAAAD__y6N_bw">