<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55266>55266</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tk missed a clear global-buffer-overflow
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shao-hua-li
</td>
</tr>
</table>
<pre>
For the following code, `clang-tk -O3 -fsanitize=address` missed the buffer-overflow `if(d[2]) {`. I checked that `-O3` did not optimize away the `if` guard, so this probably an ASAN bug. Removing `const` from `a` will make ASAN work again.
```c
const int a[1]={1};
int b;
void c(int *d) {
if (d[2]) {
b++;
}
}
main() {
c(a);
__builtin_printf("%d\n", b);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtUtuOmzAQ_RrzMgIRA7k88JCLVupLK7UfEA3YBjcGR7ZJlH59x7DJtquVLJjrOXPGbqx41G_WQeglKGuMveuxg9YKyfgR2DpvDY5dGi6Q_iggVR5HHfQfyYoTCuGk91QDg_ZeihmkmZSSLrU36RShRQitGN8KVh04q06M74BtDhTO4Bu0vWwvcyeGWEokEU9oAaMNYK9BD8QGeMfHDL_AUUk3oRNxRm8poT1cnW2wMQ_AEfa_9t9pki6Dn3KwtygpSrGjD7FXOTvEAEbnro2BAS9y6bpbdwHsUI8Zy08s379_1_ly2sWfsUCPAZCEraKw4kS6VmxD1mEpiunm5d0sqWppFTHM-F48VzFnAbSCL_b0ngQC4od4ilcsUi3DPY2BxiaMT72REyn2T-v53EzaBD2er47GUXMTZ7wi-uM4m8fI-NHzQfb_PhJRF2JX7DAJOhhZv97L81EgtEaig87Q_Zj00_tIJmfqPoSrZ8We8Tc6nQ791GStHcgx5vb8pXTDv2UbyCXkSXoyqoqv10lfI1dlji3f4Y6udcuVkOtWNtsSC4HlJk8MNtL4mpZL4kZ5hxkiCq1Oia55znle5eWqKCueZzulqqJYrXmxqpqy2rIyl7Rbk8U5Muu6xNXzSPTGPCWN9sF_JNF73Y1SznSEj1Porat9jzbtJ0yNTmb6eh7_L3U9ByA">