public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: steev@paradigmds.com To: gcc-gnats@gcc.gnu.org Subject: c++/7049: Overloading "cout <<" in one namespace obscures similar functions in a different namespace Date: Mon, 17 Jun 2002 02:13:00 -0000 [thread overview] Message-ID: <20020617084325.28172.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2002-06-17 8:46 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-06-17 2:13 steev [this message] 2002-06-17 2:16 paolo 2002-06-17 5:10 paolo 2002-06-18 4:46 c++/7049 " Philip Martin 2002-06-18 6:06 c++/7049: " paolo
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020617084325.28172.qmail@sources.redhat.com \ --to=steev@paradigmds.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).