This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11870] New: 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: 9 Aug 2003 22:43:49 -0000
- Subject: [Bug c++/11870] New: 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.
- 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
Summary: 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.
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: lachaume at mpifr-bonn dot mpg dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: /homes/lachaume/src/gcc-3.3.1/configure --with-gcc-
version-trigg
GCC host triplet: Linux pc179 2.4.10-4GB #1 Tue Feb 12 14:25:31 MET 2002
i686 unkn
The following code is unexpectedly rejected:
namespace N {
class I { };
class V { };
I in;
}
N::I& operator >> (N::I& i, N::V&) { return i; }
namespace M {
struct S {
static N::V f() { N::V t; N::in >> t; return t; }
friend N::I& operator >> (N::I&, S&);
};
}
int main() { M::S::f(); }
The output is of g++ -Wall is
bug.cpp: In static member function `static N::V M::S::f()':
bug.cpp:14: error: no match for 'operator>>' in 'N::in >> t'
bug.cpp:15: error: candidates are: I& M::operator>>(N::I&, M::S&)
It compiles perfectly without the friend declaration. It is also OK
if the friend declaration is
friend N::I& ::operator >> (N::I&, S&);
The same problem arises in prior versions of gcc (2.95.3) on the same system &
host.