From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30825 invoked by alias); 8 May 2003 18:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 30802 invoked by uid 71); 8 May 2003 18:46:01 -0000 Resent-Date: 8 May 2003 18:46:01 -0000 Resent-Message-ID: <20030508184601.30801.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, sebor@roguewave.com Received: (qmail 26536 invoked by uid 48); 8 May 2003 18:38:48 -0000 Message-Id: <20030508183848.26535.qmail@sources.redhat.com> Date: Thu, 08 May 2003 18:46:00 -0000 From: sebor@roguewave.com Reply-To: sebor@roguewave.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/10690: bogus ambiguity on templates overloaded on return type X-SW-Source: 2003-05/txt/msg00637.txt.bz2 List-Id: >Number: 10690 >Category: c++ >Synopsis: bogus ambiguity on templates overloaded on return type >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu May 08 18:46:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: sebor@roguewave.com >Release: 3.2.2 >Organization: >Environment: >Description: The attached well-formed program inspired by the CUJ 6/03 article "Function Overloading Based on Arbitrary Properties of Types," fails to compile with gcc 3.2.2. The errors after replacing the dependency on with __PRETTY_FUNCTION__ are: t.cpp:24: new declaration `template select<(!is_int::value), T>::type foo(T)' t.cpp:17: ambiguates old declaration `template select::value, T>::type foo(T)' Regards Martin >How-To-Repeat: $ cat t.cpp && g++ --version && g++ t.cpp #include template struct select { typedef T type; }; template struct select { }; template struct is_int { enum { value }; }; template <> struct is_int { enum { value = 1 }; }; extern "C" int printf (const char*, ...); template typename select::value, T>::type foo (T t) { printf ("%s:%d: %s\n", __FILE__, __LINE__, typeid (foo).name ()); return t; } template typename select::value, T>::type foo (T t) { printf ("%s:%d: %s\n", __FILE__, __LINE__, typeid (foo).name ()); return t; } int main () { foo (bool ()); foo (short ()); foo (int ()); } g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. t.cpp:26: new declaration `template select<(!is_int::value), T>::type foo(T)' t.cpp:19: ambiguates old declaration `template select::value, T>::type foo(T)' t.cpp: In function `select<(!is_int::value), T>::type foo(T) [with T = bool]': t.cpp:33: instantiated from here t.cpp:27: insufficient contextual information to determine type t.cpp: In function `select<(!is_int::value), T>::type foo(T) [with T = short int]': t.cpp:34: instantiated from here t.cpp:27: insufficient contextual information to determine type t.cpp: In function `select::value, T>::type foo(T) [with T = int]': t.cpp:35: instantiated from here t.cpp:20: insufficient contextual information to determine type >Fix: >Release-Note: >Audit-Trail: >Unformatted: