GCC rejects the following valid code: struct S { template <typename T> void operator() (T) {} }; namespace N { S s; struct A {} a; } using N::s; void f () { s(N::a); } GCC says: t.cpp:8: error: `N::s' is not a function, t.cpp:8: error: conflict with `N::s' t.cpp:14: error: in call to `s' My best guess would be that GCC does not recognize s(..) as a call to operator() on _variable_ N::s, and as such insists on finding a _function_ named 'N::s'. I haven't got a clue as to what the rest of the error message indicates or how A is involved. Comeau compiles the code without problems. I'm using GCC 3.4 20030723.
Simplified snippet: namespace N { struct A {}; struct S { void operator() (A); } s; } using N::s; void f () { s(N::A()); }
I can confirm this on the mainline (20030804). ICC 6.0 in strict mode (-Xc) accepts this code.
gcc 2.95.x compiled the code. It is rejected since gcc 3.0.
Subject: Bug 11786 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-09-08 18:46:20 Modified files: gcc/cp : ChangeLog decl2.c semantics.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/lookup: koenig2.C Log message: PR c++/11786 * decl2.c (add_function): Do not complain about seeing the same non-function twice. * semantics.c (perform_koenig_lookup): Improve documentation. PR c++/11786 * g++.dg/lookup/koenig2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3661&r2=1.3662 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.669&r2=1.670 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.357&r2=1.358 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3041&r2=1.3042 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/koenig2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 11786 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: mmitchel@gcc.gnu.org 2003-09-08 19:05:44 Modified files: gcc/cp : ChangeLog decl2.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/lookup: koenig2.C Log message: PR c++/11786 * decl2.c (add_function): Do not complain about seeing the same non-function twice. PR c++/11786 * g++.dg/lookup/koenig2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.203&r2=1.3076.2.204 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.575.2.34&r2=1.575.2.35 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.275&r2=1.2261.2.276 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/koenig2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.3.2, GCC 3.4.