From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31836 invoked by alias); 16 Aug 2004 14:53:14 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 31828 invoked by uid 48); 16 Aug 2004 14:53:14 -0000 Date: Mon, 16 Aug 2004 14:53:00 -0000 Message-ID: <20040816145314.31827.qmail@sourceware.org> From: "bangerth at dealii dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040816030839.17045.gccbugs@contacts.eelis.net> References: <20040816030839.17045.gccbugs@contacts.eelis.net> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/17045] conflict between function template and class with same name X-Bugzilla-Reason: CC X-SW-Source: 2004-08/txt/msg01538.txt.bz2 List-Id: ------- Additional Comments From bangerth at dealii dot org 2004-08-16 14:53 ------- What is really happening is that in the instantiation of ::f, the compiler sees the call f(T()); Since the argument T() is of type N::f, it has to look up the name of the function in both the global namespace and the namespace of the argument, i.e. N (Koenig lookup). It just happens to find the latter rather than the former. An example that may be a little less confusing about reusing names is this: --------------------- void h (...); template void g () { T t; h(t); } namespace N { struct S {}; struct h; } void foo () { g(); } ----------------------- g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc x.cc: In function `void g() [with T = N::S]': x.cc:11: instantiated from here x.cc:8: error: `struct N::h' is not a function, x.cc:1: error: conflict with `void h(...)' x.cc:3: error: in call to `h' W. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17045