[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is this a parser bug?
From: |
Guy Harrison |
Subject: |
Re: Is this a parser bug? |
Date: |
Tue, 19 Oct 2004 20:59:08 GMT |
User-agent: |
KNode/0.7.7 |
Marcel Loose wrote:
> Hi,
>
> I stumbled upon a GCC compiler diagnostic which, in my opinion, could
> qualify as a bug.
> When I compile the code (tBug.cc) below:
>
> #include <sys/types.h> // contains typedef for ulong
> namespace N
> {
> typedef unsigned long ulong;
> }
> using namespace N;
> int main()
> {
> N::ulong nu; // OK.
> ulong u; // Parse error. Huh?
> }
>
> I get the following compiler error:
>
> tBug.cc: In function `int main()':
> tBug.cc:10: `ulong' undeclared (first use this function)
> tBug.cc:10: (Each undeclared identifier is reported only once for each
> function
> it appears in.)
> tBug.cc:10: parse error before `;' token
Not a bug, no...
N::ulong nu;
::ulong u;
> The real problem is the ambiguity that arises when the ulong in namespace
> N is "brought into" the global namespace, because now there's two of them;
> the other ulong is defined in /usr/include/sys/types.h. So, I would expect
> a more useful diagnostic along the line of "... ulong ambiguous...",
> instead of an "... undeclared..." diagnostic.
...but admittedly it could be better phrased.