bug in gcc-2.95.2 concerning using-declarations

Gottfried Ganssauge gotti@cs.tu-berlin.de
Mon Nov 1 09:36:00 GMT 1999


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

using ::x;
using ::a;

Compiling it using gcc2.95.2 yields an error message:

Reading specs from /usr/local/lib/gcc-lib/i386-portbld-freebsd3.3/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/i386-portbld-freebsd3.3/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Di386 -Dunix -D__FreeBSD__=3 -D__i386__ -D__unix__ -D__FreeBSD__=3 -D__i386 -D__unix -Acpu(i386) -Amachine(i386) -Asystem(unix) -Asystem(FreeBSD) -D__EXCEPTIONS -D__ELF__ x.cpp /var/tmp/ccb3BIfe.ii
GNU CPP version 2.95.2 19991024 (release) (i386 FreeBSD/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/i386-portbld-freebsd3.3/2.95.2/include/g++
 /usr/local/include
 /usr/local/lib/gcc-lib/i386-portbld-freebsd3.3/2.95.2/../../../../i386-portbld-freebsd3.3/include
 /usr/local/lib/gcc-lib/i386-portbld-freebsd3.3/2.95.2/include
 /usr/include
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.3/2.95.2/cc1plus /var/tmp/ccb3BIfe.ii -quiet -dumpbase x.cc -version -o /var/tmp/ccUE118l.s
GNU C++ version 2.95.2 19991024 (release) (i386-portbld-freebsd3.3) compiled by GNU C version 2.95.2 19991024 (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 
STLport.



More information about the Gcc-bugs mailing list