This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11870] Namespace lookup failure. Inside a function of a class in a namespace, a >> b does not look ::operator>>(a, b) if an operator>> of the same namespace is declared as friend.
- From: "lachaume at mpifr-bonn dot mpg dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Aug 2003 18:49:28 -0000
- Subject: [Bug c++/11870] Namespace lookup failure. Inside a function of a class in a namespace, a >> b does not look ::operator>>(a, b) if an operator>> of the same namespace is declared as friend.
- References: <20030809224347.11870.lachaume@mpifr-bonn.mpg.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11870
------- Additional Comments From lachaume at mpifr-bonn dot mpg dot de 2003-08-11 18:49 -------
Actually. one can reproduce the error without the friend declaration, only with
the predeclaration of M::operator>> (N::I&, M::S&).
Here is a shorter example...
--nslookup3.cpp-------------
namespace N {
class A { };
class B { };
}
void operator >> (N::A&, N::B&);
namespace M {
struct S;
N::A& operator>> (N::A&, S&);
void test() {
N::B b; N::A a;
operator>>(a, b); // error
a >> b; // error, but another message ;-)
}
}
-------------------------------------
Error report:
--g++ -c -Wall-----------------------
nslookup3.cpp: In function `void M::test()':
nslookup3.cpp:19: error: could not convert `b' to `M::S&'
nslookup3.cpp:15: error: in passing argument 2 of `N::A& M::operator>>(N::A&,
M::S&)'
nslookup3.cpp:20: error: no match for 'operator>>' in 'a >> b'
nslookup3.cpp:15: error: candidates are: N::A& M::operator>>(N::A&, M::S&)
-------------------------------------
It's also weird to see two different messages for exactly the same problem,
though they're both quite logical in a sense.