W
werasm
Hi all,
I have this (minimal) piece of code that does not compile under comeau
(online) and gcc 4.2.1.
namespace n{
template <class T> struct X
{
friend int foo( X ){ return 0; }
};
}//!n
int main()
{
n::X<int> x;
return n::foo( x );
}
Comeau output:
"ComeauTest.c", line 15: error: namespace "n" has no member "foo"
return n::foo( x );
When removing the namespace qualification, everything compiles fine,
therefore...
[...as before...]
int main()
{
n::X<int> x;
return foo( x );
}
....now compiles without errors.
Changing the example slightly to here below:
namespace n{
template <class T> class X;
template <class T> int foo( X<T> )
{ return 0; }
template <class T>
struct X
{
friend int foo<>( X<T> );
};
}//!n
int m()
{
n::X<int> x;
return n::foo( x );
}
Does not result in the error (irrespective of whether n is qualified
or not). I have not checked gcc with respect to this.
Can anybody perhaps give an explanation concerning this behaviour. Is
this perhaps a compiler bug?
Kind regards,
Werner
I have this (minimal) piece of code that does not compile under comeau
(online) and gcc 4.2.1.
namespace n{
template <class T> struct X
{
friend int foo( X ){ return 0; }
};
}//!n
int main()
{
n::X<int> x;
return n::foo( x );
}
Comeau output:
"ComeauTest.c", line 15: error: namespace "n" has no member "foo"
return n::foo( x );
When removing the namespace qualification, everything compiles fine,
therefore...
[...as before...]
int main()
{
n::X<int> x;
return foo( x );
}
....now compiles without errors.
Changing the example slightly to here below:
namespace n{
template <class T> class X;
template <class T> int foo( X<T> )
{ return 0; }
template <class T>
struct X
{
friend int foo<>( X<T> );
};
}//!n
int m()
{
n::X<int> x;
return n::foo( x );
}
Does not result in the error (irrespective of whether n is qualified
or not). I have not checked gcc with respect to this.
Can anybody perhaps give an explanation concerning this behaviour. Is
this perhaps a compiler bug?
Kind regards,
Werner