This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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.


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]