This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/9885: Typedef and namespace problem - scoping silently ignored
- From: steev at paradigmds dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 28 Feb 2003 11:03:07 -0000
- Subject: c++/9885: Typedef and namespace problem - scoping silently ignored
- Reply-to: steev at paradigmds dot com
>Number: 9885
>Category: c++
>Synopsis: Typedef and namespace problem - scoping silently ignored
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Fri Feb 28 11:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Steev Wilcox
>Release: g++ 3.2.1
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
I've reported this because I typed something that g++ didn't interpret in the way I (or anyone else here) expected, and I can't find any information on what really should happen. Please accept my apologies if you know about this already - I can't find it in your bug list, though.
The following code doesn't do either of the two things that I believe would be sensible:
namespace a {}
typedef int a::b;
I can't find in Stroustrup or on the web whether this is legal or not, but I reckon this code should either (i) work, ie define b in namespace a as an int, or (ii) complain that you can't do this, because you need to typedef b inside namespace a. I think option (ii), hence "accepts-illegal".
What it actually does is silently ignore the "a::" in the typedef (even with -Wall), and typedef b globally to be an int without any warnings or errors, which doesn't seem right.
Contrast this with the case when the typedef is instead a class definition. In this case, the compiler quite rightly gives an error that you can't define a::b outside of namespace a, but then defines b globally for the rest of the file before stopping. It might be that the error in the original typedef is being suppressed somehow, but the compiler carries on in the same way.
Sorry again if this isn't actually a bug. Thanks for looking into it, Steev
>How-To-Repeat:
>Fix:
Put the typedef in the namespace
>Release-Note:
>Audit-Trail:
>Unformatted: