From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2400 invoked by alias); 24 Dec 2002 18:36:05 -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 2378 invoked by uid 71); 24 Dec 2002 18:36:00 -0000 Resent-Date: 24 Dec 2002 18:36:00 -0000 Resent-Message-ID: <20021224183600.2377.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, martin@xemacs.org Received: (qmail 1417 invoked by uid 61); 24 Dec 2002 18:27:15 -0000 Message-Id: <20021224182715.1415.qmail@sources.redhat.com> Date: Tue, 24 Dec 2002 10:36:00 -0000 From: martin@xemacs.org Reply-To: martin@xemacs.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/9053: g++ confused about ambiguity of overloaded function templates X-SW-Source: 2002-12/txt/msg01261.txt.bz2 List-Id: >Number: 9053 >Category: c++ >Synopsis: g++ confused about ambiguity of overloaded function templates >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Tue Dec 24 10:36:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Martin Buchholz >Release: g++ 3.2.1 >Organization: >Environment: Linux x86 >Description: g++ must consider whether return types of function templates lead to substitution failure before giving an ambiguity error. Considering only arguments is insufficient. These two function templates template typename bar::type foo (T); template typename qux::type foo (T); look ambiguous, but may not be if, when instantiated with a particular type, one of bar or qux leads to substitution failure. Easier to give an example than explain... The code below compiles under icc and Comeau C++, but not g++. (Also: g++ gives ambiguity errors even if foo is never instantiated, which is probably wrong.) g++ gives: ambiguous-template-bug2.cc:10: new declaration `template qux::type foo(T)' ambiguous-template-bug2.cc:7: ambiguates old declaration `template bar::type foo(T)' source code: template class bar; template <> struct bar { typedef void type; }; template class qux; template <> struct qux { typedef void type; }; template typename bar::type foo (T t) { } template typename qux::type foo (T t) { } int main (int argc, char *argv[]) { foo ("foo"); foo (7); } >How-To-Repeat: Compile source code with g++ >Fix: >Release-Note: >Audit-Trail: >Unformatted: