Bug 189 - [DR176] parse error in qualified member name lookup
Summary: [DR176] parse error in qualified member name lookup
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 2.95.2
: P3 normal
Target Milestone: 4.5.0
Assignee: Jason Merrill
URL:
Keywords: monitored, rejects-valid
: 9937 13052 13950 37350 (view as bug list)
Depends on:
Blocks: 9937 13950
  Show dependency treegraph
 
Reported: 2000-05-01 02:56 UTC by martin
Modified: 2009-12-23 23:31 UTC (History)
11 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-09-03 21:39:28


Attachments
current diff (7.31 KB, patch)
2004-12-16 14:14 UTC, Nathan Sidwell
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description martin 2000-05-01 02:56:01 UTC
 Original-Message-ID: <390CCA10.D2C4F1AE@roguewave.com>
 Date: Sun, 30 Apr 2000 18:04:32 -0600

 Hi,

 I believe this should compile according to 3.4.3.1. It fails with g++ 2.95.2.
 The compiler has no problem if A is not a template or if the call is fully
 qualified (i.e., with N::A<int>::foo()).

 Thanks
 Martin

 $ cat test.cpp

 namespace N {

 template <class T>
 struct A
 {
     int foo () const;
 };

 template <class T>
 struct B: A<T>
 {
     int foo () const;
 };

 }

 int main ()
 {
     return N::B<int>().A<int>::foo ();
 }

 $ g++ test.cpp
 test.cpp: In function `int main()':
 test.cpp:21: `struct N::B<int>' has no member named `A'
 test.cpp:21: parse error before `::'

Release:
2.95.2
Comment 1 Nathan Sidwell 2001-12-21 14:30:33 UTC
Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-Why: patch in progress
Comment 2 Nathan Sidwell 2001-12-24 13:22:03 UTC
State-Changed-From-To: analyzed->feedback
State-Changed-Why: I don't think the code is well formed.
    
    [3.4.5]/1 is the paragraph of interest, I don't see how
    [3.4.3.1] applies. this is an id-expression (which
    might be a qualified-id or an unqualified-id)
    
    We need to lookup 'A' in the class of 'B<int>'. 'A' is
    not a member of 'A<int>', so lookup does not find anything.
    We then lookup 'A' in the context of the entire expression.
    Again, this does not find anything. We therefore interpret
    the '<' as a less than operator.
Comment 3 Nathan Sidwell 2002-02-13 02:21:52 UTC
State-Changed-From-To: feedback->analyzed
State-Changed-Why: I've got a reponse from John Spicer (The edg front end
    accepts this code). The standard as written is unclear
    about class name injection, and DR 176 documents
    the problem. As that is an accepted DR, we should implement
    it (sometime...)
Comment 4 Wolfgang Bangerth 2002-11-14 14:23:58 UTC
From: Wolfgang Bangerth <bangerth@apex68.ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/189: parse error in qualified member name lookup
Date: Thu, 14 Nov 2002 14:23:58 -0600

 Re-confirmed with 3.3 CVS from 2002-11-10 and 3.2.1 pre from the same date.
Comment 5 Andrew Pinski 2003-06-15 18:16:50 UTC
Still happens on the mainline (20030615):

[zhivago2:~/src/gccPRs] pinskia% gcc pr189.cc
pr189.cc: In function `int main()':
pr189.cc:19: error: 'struct N::B<int>' has no member named 'A'
pr189.cc:19: error: expected primary-expression
pr189.cc:19: error: expected `;'
pr189.cc:19: error: expected primary-expression
pr189.cc:19: error: expected `;'
Comment 6 Andrew Pinski 2003-10-30 06:05:42 UTC
Nathan, are you still working on this?
Comment 7 Nathan Sidwell 2004-12-16 14:14:07 UTC
Created attachment 7758 [details]
current diff

This diff gets us most of the way.  However, as this is not a regression, it is
now queued until non-regression bug fixes can be applied
Comment 8 Andrew Pinski 2005-09-04 18:17:43 UTC
(In reply to comment #7)
> This diff gets us most of the way.  However, as this is not a regression, it is
> now queued until non-regression bug fixes can be applied

Your message was back in December and now it is September, 10 months later and it looks your patch 
has not been applied yet.
Comment 9 Andrew Pinski 2006-03-05 03:20:51 UTC
Any news on this?  It has been over a year since the patch has been attached to this bug.
Comment 10 Jens Maurer 2006-11-05 21:54:01 UTC
Here is a shorter test case.

namespace N {
  template<class T> struct B { int m; };
  struct C : B<int> { };
}

void g() {
  N::C().B<int>::m;
}
Comment 11 Wolfgang Bangerth 2007-03-29 16:25:34 UTC
Still happens with a recent mainline snapshot.
Comment 12 Jason Merrill 2009-11-17 04:02:38 UTC
Heh, wish I had noticed Nathan's patch before reimplementing it.
Comment 13 Jason Merrill 2009-11-17 04:03:03 UTC
Fixed.
Comment 14 Jason Merrill 2009-11-17 04:03:25 UTC
*** Bug 9937 has been marked as a duplicate of this bug. ***
Comment 15 Jason Merrill 2009-11-17 04:04:09 UTC
*** Bug 13950 has been marked as a duplicate of this bug. ***
Comment 16 Jason Merrill 2009-11-17 05:58:16 UTC
Subject: Bug 189

Author: jason
Date: Tue Nov 17 05:58:03 2009
New Revision: 154235

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154235
Log:
	PR c++/189, c++/9937, c++/13950, DR 176
	* g++.dg/tc1/dr176.C: Adjust.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/tc1/dr176.C

Comment 17 Volker Reichelt 2009-11-18 07:07:51 UTC
*** Bug 13052 has been marked as a duplicate of this bug. ***
Comment 18 Jonathan Wakely 2009-12-23 23:31:12 UTC
*** Bug 37350 has been marked as a duplicate of this bug. ***