Код ниже компилируется с помощью clang, но не компилируется с GCC (исп. 4.1.2, 4.5.4 и 4.7). 2):
template <typename T>
struct A
{
struct B { };
};
template <typename T>
bool operator==(typename A<T>::B const& b, T const& t);
enum { BAR };
template <typename T>
bool test()
{
return 0 == BAR;
}
Сообщение об ошибке из GCC 4.7.2:
a.cpp: In instantiation of ‘struct A<<anonymous enum> >’:
a.cpp:12:6: required by substitution of ‘template<class T> bool operator==(const typename A<T>::B&, const T&) [with T = <anonymous enum>]’
a.cpp:19:17: required from here
a.cpp:6:12: error: ‘<anonymous enum>’ is/uses anonymous type
a.cpp:6:12: error: trying to instantiate ‘template<class T> struct A<T>::B’
a.cpp:6:12: error: ‘<anonymous enum>’ is/uses anonymous type
a.cpp:6:12: error: trying to instantiate ‘template<class T> struct A<T>::B’
Является GCC правильным в отклонении кода, или я нахожу его ошибку?
P.S. Я видел эту ошибку, пытаясь создать один из проектов с открытым исходным кодом. Я попытался сделать наименьший возможный пример, который воспроизводит его.