Bug 9726 - namespace typedef hides global when interacting with using directive
Summary: namespace typedef hides global when interacting with using directive
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: monitored, rejects-valid
Depends on:
Blocks: 12944 23594
  Show dependency treegraph
 
Reported: 2003-02-17 16:06 UTC by Jörg Richter
Modified: 2010-06-02 19:25 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-04-16 17:25:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg Richter 2003-02-17 16:06:00 UTC
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
Comment 1 Jörg Richter 2003-02-17 16:06:00 UTC
Fix:
replacing the "typedef" with an "using" solves the problem
Comment 2 Wolfgang Bangerth 2003-02-17 23:54:58 UTC
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.
Comment 3 ckappler 2003-04-01 14:48:12 UTC
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--
Comment 4 ckappler 2003-08-03 14:18:32 UTC
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.
> 

Comment 5 Andrew Pinski 2003-08-03 14:22:32 UTC
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

Comment 6 Mike Stump 2005-11-15 23:56:53 UTC
radr://4329536
Comment 7 Andrew Pinski 2006-02-13 04:37:33 UTC
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'
Comment 8 Jason Merrill 2010-06-02 19:25:46 UTC
Fixed for 4.6.