Еще один вопрос типа "кто прав между g ++ и clang ++?" для C ++ стандартных гуру.
следующий код
template <int>
struct foo
{
template <typename>
friend void bar ()
{ }
};
int main ()
{
foo<0> f0;
foo<1> f1;
}
компилируется без проблем с clang ++ (только два предупреждения «неиспользуемая переменная»), но выдает следующую ошибку
tmp_002-11,14,gcc,clang.cpp: In instantiation of ‘struct foo<1>’:
tmp_002-11,14,gcc,clang.cpp:27:12: required from here
tmp_002-11,14,gcc,clang.cpp:20:16: error: redefinition of ‘template<class> void bar()’
friend void bar ()
^~~
tmp_002-11,14,gcc,clang.cpp:20:16: note: ‘template<class> void bar()’ previously defined here
компиляция с g ++.
Вопрос, как обычно, таков: кто прав? g ++ или clang ++?
Проверено clang ++ 3.9.1 и g ++ 6.3.0 на моей платформе Debian. Но, пробуя в Wandbox, кажется, равняется более поздним версиям.