compile following code and you will get the error at "foo a;" in main. ----------------- class foo {}; namespace bar { typedef ::foo foo; } using namespace bar; int main() { foo a; // `foo' undeclared (first use this function) } Release: gcc3.2.1 Environment: i686-pc-linux-gnu
Fix: replacing the "typedef" with an "using" solves the problem
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed with all versions of gcc since 2.95 and up to today's mainline. The error message is profoundly unhelpful. I think this is a duplicate of another report which I can't seem to find right now... W.
From: "Chris Kappler" <ckappler@cisco.com> To: "'Chris Kappler'" <ckappler@cisco.com>, <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <nobody@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>, <joerg.richter@pdv-fs.de> Cc: Subject: RE: Re: c++/9726: namespace typedef hides global Date: Tue, 1 Apr 2003 14:48:12 -0500 This is a multi-part message in MIME format. ------=_NextPart_000_0037_01C2F85D.B9191170 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit trying again after spam blocker replied to me. -----Original Message----- From: Chris Kappler [mailto:ckappler@cisco.com] Sent: Tuesday, April 01, 2003 2:40 PM To: 'gcc-gnats@gcc.gnu.org'; 'gcc-bugs@gcc.gnu.org'; 'nobody@gcc.gnu.org'; 'gcc-prs@gcc.gnu.org'; 'joerg.richter@pdv-fs.de' Subject: Re: c++/9726: namespace typedef hides global http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=97 26 I have attached an example of this bug for which the stated workaround is not sufficient. When including libraries, this type of situation can easily arise. I have been playing with include order, but I'm running out of flexibility. gcc version 3.2 20020927 (prerelease) ------=_NextPart_000_0037_01C2F85D.B9191170 Content-Type: application/octet-stream; name="nmsp.cpp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="nmsp.cpp" =0A= =0A= typedef unsigned char uchar; // comment this out and it compiles (a)=0A= =0A= namespace hide_stuff {=0A= =0A= typedef unsigned char uchar;=0A= uchar a,b,c;=0A= =0A= };=0A= =0A= =0A= #include <iostream>=0A= =0A= using namespace hide_stuff; // OR comment this out and it compiles (b)=0A= =0A= int main() {=0A= =0A= uchar d =3D 5;=0A= =0A= //cout<<a<<endl;=0A= int q =3D 1;=0A= q *=3D d;=0A= std::cout<<q<<std::endl;=0A= }=0A= ------=_NextPart_000_0037_01C2F85D.B9191170--
Subject: RE: namespace typedef hides global when interacting with using directive I have gotten this message about 10 times from you. > -----Original Message----- > From: pinskia at physics dot uc dot edu > [mailto:gcc-bugzilla@gcc.gnu.org] > Sent: Saturday, August 02, 2003 11:43 PM > To: ckappler@cisco.com > Subject: [Bug c++/9726] namespace typedef hides global when > interacting with using directive > > > PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* > gcc-bugs@gcc.gnu.org. > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9726 > > > pinskia at physics dot uc dot edu changed: > > What |Removed |Added > -------------------------------------------------------------- > -------------- > Last reconfirmed|2003-07-30 04:28:38 |2003-08-03 03:42:47 > date| | > > > > > > ------- You are receiving this mail because: ------- > You are on the CC list for the bug, or are watching someone who is. >
Subject: Re: namespace typedef hides global when interacting with using directive On Sunday, Aug 3, 2003, at 10:18 US/Eastern, ckappler at cisco dot com wrote: > I have gotten this message about 10 times from you. Set your bugzilla preferences so you do not get these messages. Thanks, Andrew Pinski
radr://4329536
The error message now is totally bogus: t.cc: In function 'int main()': t.cc:13: error: reference to 'foo' is ambiguous t.cc:2: error: candidates are: class foo t.cc:6: error: typedef class foo bar::foo t.cc:13: error: reference to 'foo' is ambiguous t.cc:2: error: candidates are: class foo t.cc:6: error: typedef class foo bar::foo t.cc:13: error: expected `;' before 'a'
Fixed for 4.6.