public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: geb@attbi.com To: gcc-gnats@gcc.gnu.org Subject: c++/7395: namespace qualification in friend causes later semantic failure Date: Wed, 24 Jul 2002 11:56:00 -0000 [thread overview] Message-ID: <20020724185502.22BA451FB@smbear.attbi.com> (raw) >Number: 7395 >Category: c++ >Synopsis: namespace qualification in friend causes later semantic failure >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Wed Jul 24 11:56:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Gary Barnes >Release: 3.0.1 >Organization: >Environment: System: Linux smbear.attbi.com 2.4.3-20mdk #1 Sun Apr 15 23:03:10 CEST 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ./configure --prefix=/usr/local >Description: A template class is given a friend template class from a related but different namespace. This prevents recognition of that friend's name in later contexts. Removal of the namespace qualification from the friend declaration eliminates the error, but the code is then illegal because the named class is not directly visible. But the code does then compile and I can make progress. >How-To-Repeat: g++ -c foo.cc -g -MMD -frepo -ansi -pedantic -fshort-enums -W -Wall -Wundef \ -Wshadow -Wpointer_arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings \ -Wconversion -Wsign-compare -Wredundant-decls -Wunreachable-code -Wmissing-declarations \ -Winline -fmessage-length=99999 -Werror -DSHOW_ERROR foo.cc:38: invalid use of undefined type `class One::Two::Three::One_Two_Three<Outer_t>' foo.cc:5: forward declaration of `class One::Two::Three::One_Two_Three<Outer_t>' foo.cc:38: template definition of non-template `void One::Two::Three::One_Two_Three<Outer_t>::In123(int)' foo.cc:5: confused by earlier errors, bailing out Remove -DSHOW_ERROR from the command line and the unit then compiles (and it should not). The error is related in some way to the namespace qualification used in the friend declaration. The contents of foo.cc are below. The error goes away if the "One::Two::Three::" qualification is removed. The unit then compiles even though it should not (One_Two_Three is not directly visible at that point). If the "One::Two::Three::" is changed to "One::Two::" then the compiler correctly states that there is no One::Two::One_Two_Three declared. If the "One:Two:Three::" is changed to just "Three::" then the error again manifests. namespace One { namespace Two { namespace Three { template <class Outer_t> class One_Two_Three { public: One_Two_Three () : I (2) {}; int I; void In123 (int _I); }; } } } namespace One { namespace Two { template <class Some_t> class One_Two { public: One_Two () : J (1) {}; int J; void In12 (int _J); private: int K; template <class Outer_t> friend class #ifdef SHOW_ERROR One::Two::Three:: #endif One_Two_Three; typedef One::Two::Three::One_Two_Three <One_Two> Friend123; Friend123 Our_Friend; }; } } template <class Outer_t> void One::Two::Three::One_Two_Three <Outer_t>::In123 (int _I) { I = _I; } template <class Some_t> void One::Two::One_Two <Some_t>::In12 (int _J) { J = _J; } int main (int, char**) { auto One::Two::One_Two <int> X; X.In12 (3); } >Fix: >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2002-07-24 18:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20020724185502.22BA451FB@smbear.attbi.com \ --to=geb@attbi.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).