Bug concerning using-declarations in gcc-2.95.1

Gottfried Ganssauge gotti@cs.tu-berlin.de
Sat Oct 23 05:50:00 GMT 1999

Consider the following source code:
extern int a();
struct x {};

using ::x;
using ::a;

Compiling it using gcc2.95.1 yields an error message:

Reading specs from =
gcc version 2.95.1 19990816 (release)
 /usr/local/lib/gcc-lib/i386-portbld-freebsd3.2/2.95.1/cpp -lang-c++ -v -D__GNUC__=3D2 -D__GNUG__=3D2 -D__GNUC_MINOR__=3D95 -D__cplusplus -Di386 -Dunix -D__FreeBSD__=3D3 -D__i386__ -D__unix__ -D__FreeBSD__=3D3 -D__i386 -D__unix -Acpu(i386) -Amachine(i386) -Asystem(unix) -Asystem(FreeBSD) -D__EXCEPTIONS -D__ELF__ x.cpp /var/tmp/ccHYhMOv.ii GNU CPP version 2.95.1 19990816 (release) (i386 FreeBSD/ELF)
#include "..." search starts here:
#include <...> search starts here:
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/i386-portbld-freebsd3.2/2.95.1/cc1plus /var/tmp/ccHYhMOv.ii -quiet -dumpbase x.cc -version -o /var/tmp/ccSj8BIS.s
GNU C++ version 2.95.1 19990816 (release) (i386-portbld-freebsd3.2) compiled by GNU C version 2.95.1 19990816 (release).
x.cpp:5: `a' is already declared in this scope

The same source code is compiled without a hitch on Borland-C++, Visual-C++
and even on egcs-1.1.2

What is the fundamental difference between using a structure in the same
namespace and using a function?
Note that declaring `using ::x' compiles fine but declaring `using ::a`
does not.

This kind of using declaration quite commonly appears in Boris Fomitchev's 

More information about the Gcc-bugs mailing list