| Issue |
76787
|
| Summary |
static constexpr data member arrays with unspecified length of template class not constant _expression_
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
beached
|
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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs