public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3423: "iterator" name lookup trouble
@ 2001-06-26  6:06 Artem Khodush
  0 siblings, 0 replies; 3+ messages in thread
From: Artem Khodush @ 2001-06-26  6:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3423; it has been noted by GNATS.

From: "Artem Khodush" <artem@duma.gov.ru>
To: <ak@ixion.net>
Cc: <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>
Subject: Re: c++/3423: "iterator" name lookup trouble
Date: Tue, 26 Jun 2001 16:51:23 +0400

 > #include <vector>
 > -------------------------------------------------------------------------------
 > using namespace std;
 > 
 > template <class T>
 > struct coord_vector {
 >   };
 > 
 > template<class T>
 > struct polygon_segment : public vector<coord_vector<T> > {
 >     void insert_c(iterator it);
 >   };
 > 
 > -------------------------------------------------------------------------------
 > This file results in a parse error in the "insert_c" line, though
 > it should probably find the superclass's iterator. 
 
 No it shouldn't, since the unqualified name 'iterator' does not
 depend on the template parameter, and according to the
 c++ standard, is looked up elsewhere but the base class.
 
 14.6 - Name resolution 
 
 -9- If a name does not depend on a template-parameter (as 
 defined in temp.dep), a declaration (or set of declarations) 
 for that name shall be in scope at the point where the name 
 appears in the template definition; the name is bound to the 
 declaration (or declarations) found at that point and this 
 binding is not affected by declarations that are visible at the 
 point of instantiation. 
 
 14.6.2 - Dependent names 
 
 -3- In the definition of a class template, ...  if a base class 
 of this template depends on a template-parameter, the base 
 class scope is not examined during name lookup until the 
 class template is instantiated. 
 
 
 So the only solution is to fix the code to make iterator
 dependent on the template parameter, as you've 
 mentioned:
 
 > >Fix:
 > qualify "iterator" with superclass name
 
 
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/3423: "iterator" name lookup trouble
@ 2001-06-26  5:24 lerdsuwa
  0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2001-06-26  5:24 UTC (permalink / raw)
  To: ak, gcc-bugs, gcc-prs, nobody

Synopsis: "iterator" name lookup trouble

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Tue Jun 26 05:24:44 2001
State-Changed-Why:
    Not a bug.  According to the standard, names from template
    parameter dependent base classes are not visible in derived
    class.  And fully-qualified name is required to access it.
    In your code, the base class of polygon_segment, 
    vector<coord_vector<T> >, depends on the parameter T.
    You have to use 'vector<coord_vector<T> >::iterator'
    instead of just 'iterator'.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3423&database=gcc


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c++/3423: "iterator" name lookup trouble
@ 2001-06-26  4:36 ak
  0 siblings, 0 replies; 3+ messages in thread
From: ak @ 2001-06-26  4:36 UTC (permalink / raw)
  To: gcc-gnats

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]

>Number:         3423
>Category:       c++
>Synopsis:       "iterator" name lookup trouble
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 26 04:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Andreas Klöckner
>Release:        3.0
>Organization:
iXiONmedia
>Environment:
System: Linux dendrite 2.4.4 #4 Don Mai 3 00:14:41 CEST 2001 i586 unknown
Architecture: i586

host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ./configure --prefix=/opt/gcc-3.0/
>Description:
#include <vector>
-------------------------------------------------------------------------------
using namespace std;

template <class T>
struct coord_vector {
  };

template<class T>
struct polygon_segment : public vector<coord_vector<T> > {
    void insert_c(iterator it);
  };

-------------------------------------------------------------------------------
	This file results in a parse error in the "insert_c" line, though
	it should probably find the superclass's iterator. The problem goes
	away if coord_vector is a non-template.
>How-To-Repeat:
	
>Fix:
	qualify "iterator" with superclass name
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-06-26  6:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-26  6:06 c++/3423: "iterator" name lookup trouble Artem Khodush
  -- strict thread matches above, loose matches on Subject: below --
2001-06-26  5:24 lerdsuwa
2001-06-26  4:36 ak

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).