K
Kaba
Hi,
GCC 4.4.5 gives compilation errors with the following code:
template <typename T>
class A {public: typedef int C;};
template <typename T>
class B: public A<T>
{
public:
using typename A<T>::C;
C operator[](int i) const { return 0; }
};
int main()
{
B<int> b;
b[2];
return 0;
}
The compilation gives:
test.cpp:9: error: ISO C++ forbids declaration of ?C? with no type
test.cpp:9: error: expected ?;? before ?operator?
test.cpp:10: error: expected ?;? before ?}? token
test.cpp: In function ?int main()?:
test.cpp:15: error: no match for ?operator[]? in ?b[2]?
In contrast, Visual Studio 2008 and Comeau C++ compile this without
errors in strict modes.
Can you see any problems here, or is it a bug in GCC?
GCC 4.4.5 gives compilation errors with the following code:
template <typename T>
class A {public: typedef int C;};
template <typename T>
class B: public A<T>
{
public:
using typename A<T>::C;
C operator[](int i) const { return 0; }
};
int main()
{
B<int> b;
b[2];
return 0;
}
The compilation gives:
test.cpp:9: error: ISO C++ forbids declaration of ?C? with no type
test.cpp:9: error: expected ?;? before ?operator?
test.cpp:10: error: expected ?;? before ?}? token
test.cpp: In function ?int main()?:
test.cpp:15: error: no match for ?operator[]? in ?b[2]?
In contrast, Visual Studio 2008 and Comeau C++ compile this without
errors in strict modes.
Can you see any problems here, or is it a bug in GCC?