From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 825 invoked by alias); 18 Jun 2002 11:36:05 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 801 invoked by uid 71); 18 Jun 2002 11:36:03 -0000 Date: Tue, 18 Jun 2002 04:46:00 -0000 Message-ID: <20020618113603.791.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Philip Martin Subject: Re: c++/7049 Overloading "cout <<" in one namespace obscures similar functions in a different namespace Reply-To: Philip Martin X-SW-Source: 2002-06/txt/msg00414.txt.bz2 List-Id: The following reply was made to PR c++/7049; it has been noted by GNATS. From: Philip Martin To: steev@paradigmds.com, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c++/7049 Overloading "cout <<" in one namespace obscures similar functions in a different namespace Date: 18 Jun 2002 12:30:14 +0100 This is not a bug, that's how name lookup works. The compiler will lookup operator<< in the anonymous namespace where the statement "cout << x" occurs, the std:: namespace where ostream is defined, and the ns:: namespace where class X is defined. Since the compiler will find an operator<< by doing this it won't look anywhere else. In particular operator<< in the global namespace will not be considered. Put operator<< for X where it belongs, in the ns:: namespace that defines class X. -- Philip