Bug 12397 - [3.4 regression] two-stage name lookup argument shadowed by global type
Summary: [3.4 regression] two-stage name lookup argument shadowed by global type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 critical
Target Milestone: 3.4.0
Assignee: Mark Mitchell
URL:
Keywords: monitored, rejects-valid
: 12694 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-09-25 07:34 UTC by Jan van Dijk
Modified: 2004-01-17 04:22 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-12-19 05:32:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan van Dijk 2003-09-25 07:34:46 UTC
struct foo { }; 
 
template <typename T> struct bar 
{ 
    bar(){} 
    int i; 
    bar (const bar<T>& foo) : i (foo.i) {} 
}; 
 
int main() 
{ 
        bar<int> b1; 
        bar<int> b2(b1); 
} 
 
With gcc-head (today) this gives: 
 
/usr/local/gcc-head/bin/g++ t.cpp 
t.cpp: In copy constructor `bar<T>::bar(const bar<T>&)': 
t.cpp:7: error: 'struct foo' has no member named 'i' 
 
Observations: 
 
It seems that in line 7 the compiler tries to access the member i 
of the global struct foo, since: 
 
1) removing struct foo solves the problem 
2) after adding a member 'int i' to struct foo the code compiles (!) 
   a member of a non-existant object seems to be accessed then. 
 
The equivalent code without templates compiles fine. 
 
Previous gcc-releases compile this code without problems. 
 
I re-read 14.6 just to be sure but assume (hope!) that this is a compiler bug. It maybe remotely 
related to the weirdness of PR12370. 
 
/usr/local/gcc-head/bin/g++ -v 
Reading specs from /usr/local/gcc-head/lib/gcc/i686-pc-linux-gnu/3.4/specs 
Configured with: ../gcc-head/configure --prefix=/usr/local/gcc-head --enable-lan 
guages=c,c++ : (reconfigured)  : (reconfigured)  : (reconfigured) 
Thread model: posix 
gcc version 3.4 20030925 (experimental)
Comment 1 Wolfgang Bangerth 2003-09-25 14:37:12 UTC
Confirmed. A regression on mainline.

W.
Comment 2 Andrew Pinski 2003-09-27 04:45:50 UTC
From Phil's regression hunter:
: Search converges between 2003-07-15-trunk (#344) and 2003-07-16-trunk (#345).
Also the error message changed from 
input.cc: In copy constructor `bar::bar(const bar&)':
input.cc:7: error: insufficient contextual information to determine type
To:
input.cc: In copy constructor `bar::bar(const bar&)':
input.cc:7: error: 'struct foo' has no member named 'i'
Between 2003-08-19 and 2003-08-20.
Comment 3 Wolfgang Bangerth 2003-10-20 19:50:02 UTC
This looks related to PR 12694.
Comment 4 GCC Commits 2003-12-22 20:52:58 UTC
Subject: Bug 12397

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-12-22 20:52:55

Modified files:
	gcc/cp         : ChangeLog typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: lookup3.C 

Log message:
	PR c++/12397
	* typeck.c (finish_class_member_access_expr): Don't tree
	IDENTIFIER_NODEs as non-dependent expressions.
	
	PR c++/12397
	* g++.dg/template/lookup3.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3830&r2=1.3831
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.516&r2=1.517
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3300&r2=1.3301
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/lookup3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Mark Mitchell 2003-12-22 20:54:00 UTC
Fixed in GCC 3.4.
Comment 6 Mark Mitchell 2003-12-22 20:55:35 UTC
*** Bug 12694 has been marked as a duplicate of this bug. ***