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

    <tr>
        <th>Summary</th>
        <td>
            constexpr std::array out-of-bounds array index in a constant expression compiles without warnings or errors
        </td>
    </tr>

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

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

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

<pre>
    The following code

```
#include <array>

constexpr std::array Array = {1, 2};

int main()
{
    return Array[3];
}
```

successfully compiles with `--std=c++20 -O3 -Wall -Werror -Wpedantic -Winvalid-constexpr` on clang 17.0.1.

[godbolt link](https://godbolt.org/z/jY13Pb1jr)

 it should not be possible to create an out-of-bounds array index in a constant expression.
 
 jfyi
 `constexpr int Array[] = {1, 2};` produces compillation error `error: array index 3 is past the end of the array (that has type 'const int[2]') [-Werror,-Warray-bounds]` as expected.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk0-PszYQxj_NcBkRGTv8O3AIm-baHipFPRp7Epw6NrLNu2_66SsI291U20MlNDZ4xnrm-TEyRnN1RB2UPZTHTM5p9KHTj_luXDZ4_eh-Hwkv3lr_btwVldcE7AjssMWKbc_zlQvjlJ01IYg3GYJ8gPjla4HyLib6OQWMSYM4gDisaXhYI4gjQt0XwN-QQ30E0X-tNi7hXRoHvAHebif1loKIGCjNwT0vg7IXUH65oj5-L3qNcVaKYrzM1j5Q-ftkLEV8N2lEqFier3KPCngPvOcM818F5mdpLeZnCsEHzM8TaemSUZifjfshrdH5P_1CxdA7VFa6Kxb1ju2K3YuTZX_1evA2oTXuz0U4b8aUpri4xE_AT9v5zocr8NNfwE-3Pwrx21DcwqcbTytMwjj62Wp0PuFAOPkYzWAJk0cVSCZC6dDPKfeXfPCz0xGfIIzT9BONQ4mreOkSLg1QjMa7TTNuy-3yMB9fKvYJdwH1AQHK47dcK4ZT8HpWFDfDrUzGO3zaCRVbNyAOL8oEmoiTjAnTSEhOo7-s22cS8CaNMuEoI6bHRAi8XnUtmqDs-epsDbxFKPuNHfC3_LzWb14sSRVDGZfWSSXSL7Ay3QndilZm1BU1EyVntWiysdNiXw91wwqSw9BUbVUpLdqykZdLq4a9yEzHGRcF52VRFbxodlQM-5YLTQWrdVtp2DO6S2N31v64L6gzE-NMXV2JimdWDmTjx7iGbknKh_kaYc-siSl-liWTLHX_OW__H_3rVPg54bsMzrhrRB-e0GI2B9v96681aZyHnfJ34KdF3bbkU_A3Ugn4ae0wAj-tTf4dAAD__zX-a4U">