public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: lerdsuwa@gcc.gnu.org
To: bangerth@ticam.utexas.edu, gcc-bugs@gcc.gnu.org,
	gcc-prs@gcc.gnu.org, nbecker@fred.net, nobody@gcc.gnu.org
Subject: Re: c++/8640: [2003-01-22] template specialization bug #2 (gcc3.2)
Date: Sun, 16 Mar 2003 12:45:00 -0000	[thread overview]
Message-ID: <20030316124510.29878.qmail@sources.redhat.com> (raw)

Synopsis: [2003-01-22] template specialization bug #2 (gcc3.2)

State-Changed-From-To: analyzed->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sun Mar 16 12:45:09 2003
State-Changed-Why:
    Not a bug.  It's the way partial ordering works.  
    To see how this works, consider a simpler example:
    
      template<typename T> void foo (T t); // #1
      template<typename U> void foo (X<U> x); // #2
    
    To find out which one is more specialized, you substitute
    function argument into another function parameter and
    try to deduce template parameter.  
    
    First, take a 't' of type 'T' from foo #1 and substitute
    into foo #2 'u' parameter of type 'X<U>' like this.  
    
      foo<U>(X<U> t); // #2, where t of is any type T
    
    You find that 't' can be any type, not necessary an 
    instantiation of class template X.  So deduction 
    of 'U' fails.  Here #1 is not more specialized than #2.
    
    On the other hand, take a 'u' of type 'X<U>' from foo #2 
    and put into foo #1:
    
      foo<T>(T x); // #1, where x of is any type X<U>
    
    You can duduce T = X<U> here.  So the deduction succeeds.
    And #2 is more specialized than #1.
    
    Deciding which specialization to use is based on the above
    algorithm (which is specified in the C++ standard).  If
    one deduction fails, and another passes, we pick the more
    specialized one.  However with your code:
    
        template<int shift1, typename T> void foo (T x);
        template<int shift2, typename T> void foo (X<U> x);
    
    'shift1' and 'shift2' cannot be deduced by the above
    method, none is more specialized than the other.  And
    both are considered during a function call.
    
    If you don't like how it works, comp.std.c++ newsgroup
    is the place to discuss about the behavior.

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


             reply	other threads:[~2003-03-16 12:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-16 12:45 lerdsuwa [this message]
2003-03-16 14:56 Giovanni Bajo

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=20030316124510.29878.qmail@sources.redhat.com \
    --to=lerdsuwa@gcc.gnu.org \
    --cc=bangerth@ticam.utexas.edu \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nbecker@fred.net \
    --cc=nobody@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).