help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is this a parser bug?


From: Marcel Loose
Subject: Is this a parser bug?
Date: Thu, 14 Oct 2004 10:56:49 +0200

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

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.

Can anyone comment on this?

Regards,

Marcel Loose.

P.S.: I compiled the code with GCC 3.2.2 and with GCC 3.4.2 and both give
the "undeclared" diagnostic.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]