<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/153764>153764</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [analyzer] False positive for clang-analyzer-security.ArrayBound
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:static analyzer,
            false-positive
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          carlosgalvezp
      </td>
    </tr>
</table>

<pre>
    Example: 

```cpp
#include <algorithm>
#include <iterator>
#include <string>

int main()
{
    std::string input[] = {
        "BBC",
 "ABC",
        "AbC",
        "aBC",
        "AB",
 "ABd",
        "abc",
        "ABCx",
    };

 std::sort(std::begin(input), std::end(input));
}
```

Error:

```
opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/predefined_ops.h:98:24: warning: Out of bound access to memory preceding 'input' [clang-analyzer-security.ArrayBound]
   98 |       { return __val < *__it; }
      |                        ^
<source>:18:5: note: Calling 'sort<std::basic_string<char> *>'
   18 |     std::sort(std::begin(input), std::end(input));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Godbolt: https://godbolt.org/z/36sa4W6nK

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE2PszYQ_jXDxQpybBzgwAHI0kMPPfYYGeMQV8ZGtkmTPfS3V4bkzb67W1WValkgz6efmWfMvVejkbIC1gA7JnwJF-sqwZ22fuT6Kt_npLfDvXq78WnWEmiNANdxH_C2xTzHI6HKCL0MEgFtuR6tU-EyAX37olRBOh6s-07ng1NmfGhwrUxAE1cGSAGkjLK8AVwjhJAPA9AaaL25IGXmJWwwENAjelnGBYQ0TQuEAGmjGAipP55fZnX_rZj_g3XzKebwrXMvvndubz_JIT8CbTboHwBaF4AUP869HNeKbIhJCaR9GUsz_KQqHwHz48eebSnenItdqD81FHBt5wCkE3aalZZuJ2-ztk46IN0oxM4bPvuLjSZa9ZsQSHcrDqdDttPKLLfdaBYg3f6Q4hQD6dL06-fR9pgISLPul0OvggfSzU4O8qyMHE529ukFaF0WQGuSRSb-yZ1Z6VKj35aA7Bn1djED4kJI71GwaJKTdXc0OynkEGkCJH8UJ0fAGqG5GXfccH1_l27npVicCve0do7fmxgM2HHrTlkgyNtn9_IGORkWZ9DpdOU6chcBqU8nFYA2aKv30_bp9WUBW4lOW28XJ2TkPa33ESCLoIwN68S1XOvH5VcyxDl5koF7JU7PsWnFhce5ileJwUi-3WL_uvv_SqsXQGBvf_2H9ZWMv9ihtzpEuJcQZh_zki6Sa1Ok1o1AuncgHT14nv1-ML8CrpOhokNJS57Iap8zRrJDyXByqfb9UIg8LzAuh4z3ucz7bJ_jrMC4OA_7c6IqggnDxZ7hgjKG00EU_JzlQ1YWJcskhwzLiSudan2dYvpEeb_Ias9ofsgSzXup_fpyErLyaH2MeFACPQn1mG5Czlx7uZutV0FdZRSzY-KqGHnXL6OHDGvlg3_lCiro9V3-EYsdURfDoGcYdLYO_TuDk8Xp6lNNVbgsfSrsFGdYX5-_3ezsH1LEyV6xxhF8wL1W5O8AAAD__zyPyDg">