public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: jan@etpmod.phys.tue.nl To: gcc-gnats@gcc.gnu.org Subject: c++/9476: lookup of member in base class template fails Date: Tue, 28 Jan 2003 13:06:00 -0000 [thread overview] Message-ID: <20030128125733.14831.qmail@sources.redhat.com> (raw) >Number: 9476 >Category: c++ >Synopsis: lookup of member in base class template fails >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Tue Jan 28 13:06:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Jan van Dijk >Release: gcc version 3.4 20030128 (experimental) >Organization: >Environment: Linux 2.5.59, glibc-2.2.5 >Description: gcc-head fails to compile he accompanying code: gcctest.cpp: In member function `void D<T>::bad()': gcctest.cpp:12: error: `i' has not been declared Qualifying i as B<T>::i (thus making i a dependent name explicitly) fixes the problem, see ugly(). To my surprise, look up of member variables is now different from that of member functions: f() does not need to be qualified (see good()). Comments from Nathan Sidwell on the mailing list: refer to 14.6/8 in your example both i and f are non-dependent names so the usual lookup rules apply. 3.4.1, 3.4.2. 3.4.1 deals with non-function call unqualified name lookup (i), and 3.4.2 deals with unqualified names used for function calls. That uncludes koenig lookup. In this case there are no template-dependent arguments, so the koenig lookup should be resolved at parse time. (see example in 14.6/9) <snip> void good(){ f(); } // no B<T>:: required If you said &f;, you'd get the same error. I think this is a bug, please file a bug report. >How-To-Repeat: template <class T> struct B { int i; int f(); }; template <class T> struct D : public B<T> { void good(){ f(); } // no B<T>:: required void bad(){ i=0 // does not compile void ugly(){ B<T>::i=0; } // ... this does. }; >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2003-01-28 13:06 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-01-28 13:06 jan [this message] 2003-01-28 13:14 nathan 2003-01-28 15:26 Jan Van Dijk 2003-01-28 15:56 Nathan Sidwell
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=20030128125733.14831.qmail@sources.redhat.com \ --to=jan@etpmod.phys.tue.nl \ --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).