<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63886>63886</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[ASan] fails to detect OOB access due to builtin optimization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
N-R-K
</td>
</tr>
</table>
<pre>
Minimal reproducible code-snippet:
```c
#include <string.h>
int main(void)
{
char s[1] = "A";
return strlen(s);
}
```
Compile command: `clang -O1 -g3 -fsanitize=address,undefined`
Expected behavior: ASan should catch the OOB access.
Reality: It gets optimized out and returns 1 always.
Note: adding `-fno-builtin` or `-O0` allows ASan to be effective.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcktFuozAQRb_GvIyIwA4EHnhImkZarbaRul9g7AnMytjINum2X78ySdpqJQSCmXuZM74yBBosYseqA6uOmVzi6Hz3kr_mP7Pe6ffuF1mapAGPs3d6UdQbBOU05sHSPGNkYs-KIyse97q4Xer-zgVZZRaNwMRTiJ7ssBmZeP4uIhthkmQZb66ONOPtvbo7PNpaNUoPgVWHklVHYOIIjPM945yJryaPcfEWQvQGk1tIVp_13fG_Gb_P8OSmmVa2aZJWM7GHRGGkHSA_l5APAvJLkJYifSATR6m1xxAYf1qsxgtZ1J-Wz39nVBE19DjKKzmf7Pa_pYUwusVoUDKqEeKIcD4fQCqFIWxu2leUhuJ7UvyIMGAM4OZIE32gBrdEkFbDDTRACdK8yfeH9sVFTEKpNdkhAeQX6_J-IRPJsroA59ev54QP0hj3Fm6DRQc9Al4uqCJd8W6Y6U7oVrQyw66sm3a73ZVlmY1di2W_03VbNEIqsW0Qd7JqC9U0dSWqps-o4wUXxa6syqYqq3LT8-pSN-W25Q1yLCq2LXCSZDbGXKeN80NGISzY1aJp6szIHk1Yc8m5xTdYi-m4q2Pmu6TJ-2UIbFsYCjF8uUSKZg10wkpZuUgyIfFpjKjit42DXnAFv-3nsWcZydls8aYbY5xDSjg_MX4aKI5Lv1FuYvyU_nd_5LN3f1BFxk_rlIHx00rxLwAA__8y2QaZ">