| Issue |
76362
|
| Summary |
constexpr std::array out-of-bounds array index in a constant _expression_ compiles without warnings or errors
|
| Labels |
|
| Assignees |
|
| Reporter |
dyumin
|
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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs