Bug 23594 - namespace typedef and global typedef name the same type, using kills global
Summary: namespace typedef and global typedef name the same type, using kills global
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
: 24758 44333 (view as bug list)
Depends on: 9726
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-27 12:58 UTC by Yuri
Modified: 2010-06-02 19:25 UTC (History)
3 users (show)

See Also:
Host: FreeBSD on i386
Target:
Build:
Known to work:
Known to fail: 2.95.3 3.2.3 3.4.0 4.0.0 4.1.0 3.0.4
Last reconfirmed: 2010-06-02 18:24:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri 2005-08-27 12:58:41 UTC
I have the same typedef in global scope and in the namespace.
Also I have "using" clause for this namespace.

If both typedefs are in place further code doesn't see typedefed type at all.
See example below.

Yuri

--begin code--
typedef int COUNT;

namespace NN {
  typedef int COUNT;
};
using namespace NN;

COUNT xx;
--end code--

gives an error:
error: `COUNT' does not name a type
Comment 1 Andrew Pinski 2005-08-27 15:19:14 UTC
Confirmed, not a regression.
Note if they were two differrent types then this would be invalid code.



PS. the semicolon after the end of the namespace really makes this code invalid but since this is not 
what the bug is about I am going to ignore it (we do error out with -pedantic).
Comment 2 Yuri 2005-08-27 16:59:56 UTC
(In reply to comment #1)
...
> PS. the semicolon after the end of the namespace really makes this code
invalid but since this is not 
...
I didn't get why semicolon makes it invalid.
I thought semicolon is allowed between any statements.
Comment 3 Andrew Pinski 2005-08-27 17:05:05 UTC
(In reply to comment #2)
> (In reply to comment #1)
> ...
> > PS. the semicolon after the end of the namespace really makes this code
> invalid but since this is not 
> ...
> I didn't get why semicolon makes it invalid.
> I thought semicolon is allowed between any statements.
Because namespace (and extern "C") blocks are not statements.
Comment 4 Andrew Pinski 2005-11-09 17:03:25 UTC
*** Bug 24758 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2005-11-09 17:25:07 UTC
Related to PR 9726.
Comment 6 Paolo Carlini 2010-06-02 17:37:08 UTC
*** Bug 44333 has been marked as a duplicate of this bug. ***
Comment 7 Jason Merrill 2010-06-02 19:25:30 UTC
Fixed for 4.6.