K
kcsasquatch
All,
I have the following C++ code that does not compile under gcc 4.2.1 or
4.4.3. It *does* compile on http://comeaucomputing.com/tryitout/
version 4.3.10.1 Beta2.
Is this valid C++ code (as it seems), or is there a real syntax error
that Comeau is not catching?
template<typename T>
class A
{
public:
template<int Flags>
void foo(T *text)
{
return;
}
};
template<typename T>
class B : public A<T>
{
public:
typedef A<const char> base;
template<int Flags>
void foo(T *text)
{
A<T>::foo<Flags>(text); // ERROR
static_cast<A<T>*>(this)->foo<Flags>(text); // OK
base::foo<Flags>(text); // OK
}
};
int main()
{
B<const char> b;
b.foo<1>("bar");
return 0;
}
% g++ main.cpp
main.cpp: In member function ‘void B<T>::foo(T*) [with int Flags = 1,
T = const char]’:
main.cpp:32: instantiated from here
main.cpp:23: error: invalid operands of types ‘<unresolved overloaded
function type>’ and ‘int’ to binary ‘operator<’
If it's an error, the gcc error message could be improved
Tested on following compilers:
$ g++ --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Thanks in advance,
Kevin Campbell
I have the following C++ code that does not compile under gcc 4.2.1 or
4.4.3. It *does* compile on http://comeaucomputing.com/tryitout/
version 4.3.10.1 Beta2.
Is this valid C++ code (as it seems), or is there a real syntax error
that Comeau is not catching?
template<typename T>
class A
{
public:
template<int Flags>
void foo(T *text)
{
return;
}
};
template<typename T>
class B : public A<T>
{
public:
typedef A<const char> base;
template<int Flags>
void foo(T *text)
{
A<T>::foo<Flags>(text); // ERROR
static_cast<A<T>*>(this)->foo<Flags>(text); // OK
base::foo<Flags>(text); // OK
}
};
int main()
{
B<const char> b;
b.foo<1>("bar");
return 0;
}
% g++ main.cpp
main.cpp: In member function ‘void B<T>::foo(T*) [with int Flags = 1,
T = const char]’:
main.cpp:32: instantiated from here
main.cpp:23: error: invalid operands of types ‘<unresolved overloaded
function type>’ and ‘int’ to binary ‘operator<’
If it's an error, the gcc error message could be improved
Tested on following compilers:
$ g++ --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Thanks in advance,
Kevin Campbell