public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: nathan@gcc.gnu.org
To: dbeck@beckground.hu, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	nathan@gcc.gnu.org
Subject: Re: c++/9865: [3.2/3.3/3.4 regression] Template matching for reference types
Date: Thu, 27 Mar 2003 14:04:00 -0000	[thread overview]
Message-ID: <20030327140144.15458.qmail@sources.redhat.com> (raw)

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 <typename T> struct Foo; //#1
    template <typename T> struct Foo<const T>; //#2
    Foo<short &> ;;// #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 <typename T> struct foo<T &>;

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9865


             reply	other threads:[~2003-03-27 14:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-27 14:04 nathan [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-03-06 20:57 jason
2003-03-06 18:04 jason
2003-02-26 17:52 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030327140144.15458.qmail@sources.redhat.com \
    --to=nathan@gcc.gnu.org \
    --cc=dbeck@beckground.hu \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gcc-prs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).