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

    <tr>
        <th>Summary</th>
        <td>
            Clang doesn't warn about reading beyond the end of a source sequence.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    GCC reports warning for calls to string manipulation functions such as memchr, or strcpy that are determined to read past the end of the source sequence ([-Wstringop-overread])

Similar warnings are not reported in Clang.

Sample Program:
```
#include <string.h>

int main () {
        int dest[10];
        int src[5] = {1,2,3,4,5};
 memcpy (dest, src, 10*sizeof (int));
        return 0;
}
```

Compilation with Clang:
No warnings reported
```
# clang  -c -Wall stringop_overread.c
#
```
Compilation with GCC:
```
# gcc -c -Wall stringop_overread.c
stringop_overread.c: In function _main_:
stringop_overread.c:6:9: warning: memcpy reading 40 bytes from a region of size 20 [-Wstringop-overread]
    6 |         memcpy (dest, src, 10*sizeof (int));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stringop_overread.c:5:13: note: source object src of size 20
    5 |         int src[5] = {1,2,3,4,5};
      | ^~~
```
Compiler Versions:
```
clang version 16.0.6 
gcc (GCC) 13.2.1
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU2P4zYM_TXMhYhhS5E_Dj4kzmbRS1GgQPc4UGQmVmFLriTPIj30txdynMxMJzMtukZgKyb5qEc-ytJ7fTZENYgdiP1KTqGzrh4m35Gxl9XRtpf6a9Ogo9G64PG7dEabM56sQyX73mOw6IOL7wZp9Dj1Mmhr8DQZFRce_aQ6lB4HGlTngDVoXQxR4wVDJwNKR9hSIDdoQ20EdCRbHKUPGDpCMi3a07z0dnKK0NMfExlFCKwEsVt_u-7Ajmv7TC5Gg9gDqyDdQ7q93n_Vg-6luzHwc1pjw0KNWtQGm16ac_ImTA5jT_iLs2cnB-DLa8jT5Xf9y7g2qp9aQuDNdTdJB_zLayhtAg5Sm3nXrEIodlcDLld0aMkHELssjQz4AwfvFIidALFH4PsIkgFrGLCGA2s2wBoBxavQWPbxEnPO0KyZEViDWQps6_WfZE_Rqk2IFWPVu6yOwuQMpndDxH9Yhfne2GHUiwq-69Bdi3qv3M_2pQW30n9UU1QxFHGtcP1N9j3e-vx063Oi7s4PQd5t5mvTfNJEPCv1H7I9MvAt_vQie3yKnX66p3ockQPfVjFyqUhcLv2KPnGoNikeL4E8npwdUKKjc4S3J4ytQ5bixwNw72KOUDS3dv6wIiIWiC9__ev1GXUBfJvxSNjYQPG5zLY9_k5qlvkrki_pxRsq_2cg3nL4RDXk8DdyPh5iH0nmqs_nqxdmeZImOV5NUUnAyqg3VmHGE5ZkDzFWbc3bildyRXVWpNWmzATPV11diLbN6ESS2k1RVLngFdtkJcvLspJFoVa6ZinbpDzlmRClyJNTzqosL_JSiUpKKWCT0iB1n_T985BYd15p7yeqS16wctXLI_V-PvoZm5kAY_Er4Orovz5OZw-btNc--BeEoENP9TzT2FryBlgRZgGjPNop3JV7pIs17esTXP7z_E5Wk-vrLoRxrjA7ADucdeimY6LsAOwQsy6P9ehsVAaww0zCAzvMPP4OAAD__zT6BLk">