This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/1883: Function lookup in template constructors fails when using namespace.
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/1883: Function lookup in template constructors fails when using namespace.
- From: Carlo dot Wood at alinoe dot com
- Date: Tue, 6 Feb 2001 06:02:24 +0100
>Number: 1883
>Category: c++
>Synopsis: Function lookup in template constructors fails when using namespace.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Feb 05 21:06:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Carlo Wood <carlo@alinoe.com>
>Release: 2.97 20010122 (experimental)
>Organization:
>Environment:
System: Linux ansset 2.4.0-test10 #2 Thu Nov 2 10:05:20 CET 2000 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-cvs/configure --prefix=/usr/local/gcc --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ : (reconfigured) : (reconfigured) ../gcc-cvs/configure --prefix=/usr/local/gcc --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++
>Description:
A function which is declared in a namespace will not be seen in the
constructor of a template class when the namespace is not explicitely
given (ie N::n() works) but a "using namespace N;" is used instead.
>How-To-Repeat:
The following code snippet reproduces the error:
-----------------------------------------------
namespace N
{
void n(void) { }
}
template<typename T>
class A {
public:
A(void)
{
using namespace N;
n();
}
};
class B { };
A<B> a;
-----------------------------------------------
g++-cvs -v -c test.cc
Reading specs from /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc-cvs/configure --prefix=/usr/local/gcc --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ : (reconfigured) : (reconfigured) ../gcc-cvs/configure --prefix=/usr/local/gcc --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++
gcc version 2.97 20010122 (experimental)
/usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/cc1plus -v -iprefix /usr/local/bin/../lib/gcc-lib/i686-pc-linux-gnu/2.97/ -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0
-D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ test.cc -D__GNUG__=2 -D_GNU_SOURCE -D__GXX_ABI_VERSION=100 -quiet -dumpbase test.cc -version -o /tmp/ccxY4RYU.s
GNU CPP version 2.97 20010122 (experimental) (cpplib) (i386 Linux/ELF)
GNU CPP version 2.97 20010122 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 2.97 20010122 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 2.97 20010122 (experimental).
ignoring nonexistent directory "/usr/local/include/g++-"
ignoring nonexistent directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/local/gcc/i686-pc-linux-gnu/include/g++-"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc/include/g++-
/usr/local/include
/usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/include
/usr/local/gcc/i686-pc-linux-gnu/include
/usr/include
End of search list.
test.cc: In constructor `A<T>::A() [with T = B]':
test.cc:18: instantiated from here
test.cc:12: `n' undeclared (first use this function)
test.cc:12: (Each undeclared identifier is reported only once for each function
it appears in.)
>Fix:
A work around is to explicitely give the namespace and write:
N::n();
>Release-Note:
>Audit-Trail:
>Unformatted: