У меня есть проблема с этим фрагментом кода:
template <typename T>
struct S
{
static int a;
};
template <typename T>
decltype(S<T>::a) S<T>::a;
clang-3.4
говорит:
s.cpp:8:25: error: redefinition of 'a' with a different type: 'decltype(S<T>::a)' vs 'int'
decltype(S<T>::a) S<T>::a;
^
s.cpp:4:14: note: previous definition is here
static int a;
^
1 error generated.
Но gcc-4.8.2
принимает. Какой из компиляторов прав? Должен ли я избегать такого кода в будущем?