We have this kind of code:
template <typename T>
struct A {
static constexpr A a = A{};
};
template <typename T>
struct B {
T a;
};
B<A<int>> b;
GCC 13 seems happy with L.3 but not clang 16.
<source>:3:21: error: constexpr variable cannot have non-literal type 'const A<int>'
static constexpr A a = A{};
^
<source>:9:4: note: in instantiation of template class 'A<int>' requested here
T a;
^
<source>:12:11: note: in instantiation of template class 'B<A<int>>' requested here
B<A<int>> b;
^
<source>:3:21: note: incomplete type 'const A<int>' is not a literal type
static constexpr A a = A{};
^
<source>:2:8: note: definition of 'A<int>' is not complete until the closing '}'
struct A {
^
1 error generated.
Compiler returned: 1
https://godbolt.org/z/brYMf9har
Which compiler is correct?