This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug concerning using-declarations in gcc-2.95.1
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Bug concerning using-declarations in gcc-2.95.1
- From: Gottfried Ganssauge <gotti at cs dot tu-berlin dot de>
- Date: Thu, 21 Oct 1999 17:08:09 +0200 (CEST)
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 =
/usr/local/lib/gcc-lib/i386-portbld-freebsd3.2/2.95.1/specs
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:
/usr/local/lib/gcc-lib/i386-portbld-freebsd3.2/2.95.1/include/g++
/usr/local/include
/usr/local/lib/gcc-lib/i386-portbld-freebsd3.2/2.95.1/../../../../i386-portbld-freebsd3.2/include
/usr/local/lib/gcc-lib/i386-portbld-freebsd3.2/2.95.1/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.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
STLport.