This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11744] New: Wrong namespace lookup when induced by a template parameter
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Jul 2003 13:23:23 -0000
- Subject: [Bug c++/11744] New: Wrong namespace lookup when induced by a template parameter
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11744
Summary: Wrong namespace lookup when induced by a template
parameter
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nicolas dot burrus at lrde dot epita dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
Considering the following code:
namespace nsp_foo {
struct A {};
struct foo {};
}
namespace nsp_bar {
void foo(nsp_foo::A) {}
template <class T>
void bar(T t)
{
nsp_bar::foo(t); // line 16
}
}
int main()
{
nsp_bar::bar(nsp_foo::A());
}
Here is g++-3.4 output:
namespaces.cc: In function `void nsp_bar::bar(T) [with T = nsp_foo::A]':
namespaces.cc:23: instantiated from here
namespaces.cc:5: error: `struct nsp_foo::foo' is not a function,
namespaces.cc:11: error: conflict with `void nsp_bar::foo(nsp_foo::A)'
namespaces.cc:16: error: in call to `foo'
This would be normal if line 16 was a call to "foo(t)" without
namespace prefix, as koenig lookup is done in the namespace of
template parameters. But using of the "nsp_bar::" prefix, the call to
foo should not be ambiguous. g++-3.3, como and icc accept this code.
It works correctly if bar is non template "void bar(nsp_foo::A)".
Environment:
System: Linux ouagadougou 2.4.21 #1 Fri Jul 25 11:19:01 CEST 2003 i686 GNU/Linux
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../../lrde/ext/gcc/configure --prefix=/home/lrde/lrde/usr/gcc-3.4 --enable-languages=c,c++ : (reconfigured) : (reconfigured) ../../lrde/ext/gcc/configure --enable-languages=c,c++ --prefix=/home/lrde/lrde/usr/gcc-3.4 : (reconfigured) ../../lrde/ext/gcc/configure --enable-languages=c,c++ --prefix=/home/lrde/lrde/usr/gcc-3.4 : (reconfigured) : (reconfigured) /home/lrde/stud/burrus_n/work/lrde/ext/gcc/configure --prefix=~lrde/usr/gcc-3.4 --enable-languages=c,c++ : (reconfigured) /home/lrde/stud/burrus_n/work/lrde/ext/gcc/configure --prefix=~lrde/usr/gcc-3.4 --enable-languages=c,c++ : (reconfigured) /home/lrde/stud/burrus_n/work/lrde/ext/gcc/configure --prefix=~lrde/usr/gcc-3.4 --enable-languages=c,c++ : (reconfigured) /home/lrde/stud/burrus_n/work/lrde/ext/gcc/configure --prefix=/home/lrde/lrde/usr/gcc-3.4 --enable-languages=c,c++
How-To-Repeat:
Compile the given code.