<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76787>76787</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
static constexpr data member arrays with unspecified length of template class not constant expression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
beached
</td>
</tr>
</table>
<pre>
The following code fails to compile
https://godbolt.org/z/qjsq5br6e
```cpp
template<typename>
struct S {
static constexpr int arr[] = {1,2,3};
};
constexpr int foo( int x ) {
return S<void>::arr[x];
}
constexpr int x = foo(1);
```
One can work around the issue by rewriting foo like
```cpp
constexpr int foo(int x) {
return ((void)S<void>::arr[0]),S<void>::arr[x];
}
```
or if S is not a template.
This is accepted by gcc/clang and I did not see anything in [expr.const] or [class.static] preventing it.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVM2O2zYQfprRZRBDJq2_gw673hroqYfNC1DkSGJCkQpJre0-fUFq09RN9hBAGBEjzs_3zXwSIejJEvVQPUP1Uogtzs73Awk5kyoGp-7955lwdMa4q7YTSqcIR6FNwOhQumXVhhDKFyifdjvHuAbgT8AuwC6TU4Mz8eD8BOzyN7DLty_hWzX4mt6D6nJ_5LrunkjLakQk4Od4X8mKhYD_sX8L0W8y4itC87x7EBFDFFFLlM6GSLfVo7YRhfc7KgT-ku4fgZ0ZsDOH5gX4e_jDOdvHLKNzwNp8vCGw7rGwp7h5i6_Az29Oq9QmfwL-tNe-QfVY6MMqt9zjXusIrPsR9Z2d_8b-ZQmlsHh1_isK7zarMM6EOoSNcLijp6vXMY1rdA6N_vo4oZ8p_xXm3NdHiIG1wNqMmXUfwC8TfNYBO_8eP7-C7DzqEV9RB7QuosDvS3J4AJbt51mHdFFISWsklRiZpAR2kUbYCYVV-CcqrXKqQITC3uOc6NIWoXpORBwyJWl7nE8-aUQIh33Rknf19EY2c6zjoVA9Vx3vREH9sSlPrG5OLS_mvuPHsTuJqpENjeMgxFi31NTHjrVM1upY6J6V7FQeS142vC35oaqUpEpQc6T6VMsWTiUtQpuDMW9LklGRx9w3ddM2hREDmZDly5il674DwFhSs-9TzKdhmwKcSqNDDD-yRB0N9T8pR4kocKFlIJ8UJO4BrzrOuNmwktSjJoWG7BRndOO_U8BMT-YzpxI2YkpHIWhni82b_n-_BR3nbThItwC7pJ7eX59W776QjMAuGUkAdslI_wkAAP__DTtqEQ">