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

    <tr>
        <th>Summary</th>
        <td>
            Unsafe buffer usage: false positive
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          andrew-aitchison
      </td>
    </tr>
</table>

<pre>
    // Ubuntu clang version 16.0.0 (1~exp5ubuntu3)
// clang++-16 -Wunsafe-buffer-usage -c -o unsafe.o unsafe.cpp

```
int f(const int a[10])
{
    return a[1];
}

```

unsafe.cpp:8:17: warning: 'a' is an unsafe pointer used for buffer access [-Wunsafe-buffer-usage]
int f(const int a[10])
      ~~~~~~~~~~^~~~~
unsafe.cpp:10:12: note: used in buffer access here
    return a[1];
           ^
1 warning generated.

Since the size of array 'a' is known, and known to be fixed, at compile-time, the access is safe *and* the compiler can determine this, so the warning is a false positive.

While I appreciate that `std::span` would be better, there is much code out there that is not ready for C++20.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlEuPpDYQxz9NcSnRwubR9IEDvb0t5Ryt9mxMAU5oG_kxvZPDfvbIhtmZbKIkFvKzqvjV3w_hnJo1UQf1FepbJoJfjO2EHi09c6G8XJQzOhvM-NoBvwO_45chaB9QrkLP-ELWKaORNafiVCDwln2nb1sdklEJ_ALFDYr-8E1OwK_ArzlrMP8atBMT5UOYJrJ5cGImzCXmBveV04-O3LYj1F43xfGlodIeJ-CtNNp5jCMB9ZUVUN_eGc7XvYOIaMkHq3eraFRe34xu__Kbvf5AVPYtlD07Q9njU1it9By7wM8C-BmVQ6GPDHAzSnuyGByNOBmLe9YopCTnEOrrP-oR6f53jpjK9x8F6s-p-Ts3K2LFI602nmKbwJT-iWshS_-tG74XqD_vc-xNEpxJkxWextNHHX9VWhL6hdCpPwjNhMJa8fpRvd-1eWrgn1DocR-gNzgQTuobjWnBozSPTa2Ue_WgOBUjHvDKYdIeeC_0CLxPi4eDRSk0juTJPpSOJMpFf2eS1Rt83EScxOriFjrl1Qv9JY2vi1oJf0GxbZakEj5GEh6hKZwfoeyh7N0mNDQFPk1Yx8g_kPdkD1pL8SePIBeUZiQ0wR_TKZBycYvQkhhf08H5tF8hXhwc2diV46W8iIw61lxYW7XnkmVLR9Ug6guvmRyappFTRayS5TQ0VBVMiDZTHS94WbSMs7Jua3Yq22qaLo2MXpd6GKAq6CHUelrXl8fJ2DlTzgXqmqqpmmwVA60uvR6ca3piWgTO42Niu-iTD2F2UBWrct69R_HKr9R92W_GceD24172P4mdBbt2i_ebi1qmh2RWfgnDSZoH8HuMeTT5Zs1vJD3weyJxwO-J9M8AAAD__y8cgog">