| Issue |
177810
|
| Summary |
Clang complains on constexpr initializer for static template member
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
kandid
|
```c++
// 1. Both gcc and clang have no problems with the following piece of code
struct B {
static B const _Const;
constexpr B(int b) : _b(b) {}
int _b;
};
constexpr B B::_Const{3};
static constexpr B _GlobalB = B::_Const;
int foo_b() {
return _GlobalB._b;
}
// 2. The same code as above, but the struct is now templated (and b,B replaced by a,A).
// gcc still compiles this, but clang generates an error on _GlobalA
template <typename Arg> struct A {
static A const _Const;
constexpr A(int a) : _a(a) {}
int _a;
};
template <typename Arg> constexpr A<Arg> A<Arg>::_Const{3};
static constexpr A<int> _GlobalA = A<int>::_Const;
int foo_a() {
return _GlobalA._a;
}
```
Since I didn't find any clue in the [C++ reference](https://en.cppreference.com/w/cpp/language/static.html) that template classes should behave different to non templates in this case, I assume an inaccuracy on clang's side. Please see the sample on [godbolt](https://godbolt.org/z/fbMoG5Max).
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs