From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15476 invoked by alias); 27 Mar 2003 14:01:44 -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 15459 invoked by uid 48); 27 Mar 2003 14:01:44 -0000 Date: Thu, 27 Mar 2003 14:04:00 -0000 Message-ID: <20030327140144.15458.qmail@sources.redhat.com> To: dbeck@beckground.hu, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nathan@gcc.gnu.org From: nathan@gcc.gnu.org Reply-To: nathan@gcc.gnu.org, dbeck@beckground.hu, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nathan@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: c++/9865: [3.2/3.3/3.4 regression] Template matching for reference types X-SW-Source: 2003-03/txt/msg01899.txt.bz2 List-Id: Synopsis: [3.2/3.3/3.4 regression] Template matching for reference types State-Changed-From-To: analyzed->closed State-Changed-By: nathan State-Changed-When: Thu Mar 27 14:01:43 2003 State-Changed-Why: Not a bug. It is doing exactly what the standard says. template struct Foo; //#1 template struct Foo; //#2 Foo ;;// #1 or #2? 14.5.4.1/2 says a partial specialization matches if the template arguments of the partial specialization can be deduced from the actual template argument list. So, can 'const T' deduce a T from 'short &'? One deduction is that T is 'short &', which leads to a const qualified reference type. [8.3.2]/1 says that that's ill-formed *except* when the cv qualifiers are introduced through the use of a typedef or of a template type argument, in which case they are ignored. So the partial specialization #2 is selected, rather than the primary template #1. That is PR 2645. DR295 was the similar case for function types, and I think it is bad for exactly the same reasons PR 9865 is giving a surprise. To avoid the surprise, you need another partial specialization template struct foo; http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9865