From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21356 invoked by alias); 29 Jul 2010 14:48:24 -0000 Received: (qmail 21106 invoked by uid 48); 29 Jul 2010 14:47:57 -0000 Date: Thu, 29 Jul 2010 14:48:00 -0000 Subject: [Bug c++/45132] New: Inconsistant function overloading between template and non-template functions X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "g_sauthoff at web dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg03224.txt.bz2 Consider following test-case: $ cat templorder.cc #include struct Foo { int a; char b; }; template inline int match(const T &x) { return 23; } template inline int not_match(const T &x) { return match(x) + 1; } template <> inline int match(const int &x) { return 42; } inline int match(const Foo & x) { return 52; } inline int match(const double &d) { return 62; } #define CHECK_EQ(A, B) if (!((A) == (B))) { ++r; std::cerr << "Error: " << (A) << " != " << (B) << '\n'; } int main() { int r = 0; int i = 0; CHECK_EQ(not_match(i), 43); char c = 0; Foo f; CHECK_EQ(not_match(f), 53); double d = 0; // BANG CHECK_EQ(not_match(d), 63); return r; } $ g++ temporder.cc $ ./a.out Error: 24 != 63 This behavior is inconsistant, because either 'CHECK_EQ(not_match(f), 53)' should fail, too or 'CHECK_EQ(not_match(d), 63)' should not fail. I would expect that 'CHECK_EQ(not_match(d), 63)' should not fail. But perhaps I am missing some rule in the C++ standard. Compiling the test case with the C++ Sun Workshop Pro CC and executing prints no errors. $ cat /etc/issue Ubuntu 10.04.1 LTS But I got the same output with g++ under the previous two Ubuntu versions. -- Summary: Inconsistant function overloading between template and non-template functions Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: g_sauthoff at web dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45132