From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31735 invoked by alias); 17 Jun 2002 08:46: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 31655 invoked by uid 71); 17 Jun 2002 08:46:01 -0000 Resent-Date: 17 Jun 2002 08:46:01 -0000 Resent-Message-ID: <20020617084601.31654.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, steev@paradigmds.com Received: (qmail 28174 invoked by uid 61); 17 Jun 2002 08:43:26 -0000 Message-Id: <20020617084325.28172.qmail@sources.redhat.com> Date: Mon, 17 Jun 2002 02:13:00 -0000 From: steev@paradigmds.com Reply-To: steev@paradigmds.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7049: Overloading "cout <<" in one namespace obscures similar functions in a different namespace X-SW-Source: 2002-06/txt/msg00381.txt.bz2 List-Id: >Number: 7049 >Category: c++ >Synopsis: Overloading "cout <<" in one namespace obscures similar functions in a different namespace >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Jun 17 01:46:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Steev Wilcox >Release: 3.1 (sparc-sun-solaris2.8) >Organization: >Environment: Solaris 8 >Description: If you define a operator<<(ostream&,thing) for an object X in one namespace, then in another namespace, define the same sort of function for a different object Y, it hides the original function so you can't print objects of type X in the namespace associated with object Y. Fairly obvious workaround: don't define operator<<'s in namespaces - make sure they always go in the global namespace. Bjarne wouldn't be pleased, though. I'm not 100% certain this is a bug and not a "feature" of C++ - it just looks suspicious. I haven't been able to find this in the list of known bugs, but it doesn't mean it's not there. Thanks for your time, Steev >How-To-Repeat: Compile bug2.cpp with "g++ -c bug2.cpp". It'll fail in the way indicated in file "testout". If you place the definition of the operator<< on Y in the global namespace, g++ can suddenly find the definition of operator<< on X. >Fix: For workaround, see above. >Release-Note: >Audit-Trail: >Unformatted: