From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29913 invoked by alias); 16 Mar 2003 12:45:10 -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 29879 invoked by uid 48); 16 Mar 2003 12:45:10 -0000 Date: Sun, 16 Mar 2003 12:45:00 -0000 Message-ID: <20030316124510.29878.qmail@sources.redhat.com> To: bangerth@ticam.utexas.edu, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nbecker@fred.net, nobody@gcc.gnu.org From: lerdsuwa@gcc.gnu.org Reply-To: lerdsuwa@gcc.gnu.org, bangerth@ticam.utexas.edu, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nbecker@fred.net, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: c++/8640: [2003-01-22] template specialization bug #2 (gcc3.2) X-SW-Source: 2003-03/txt/msg01060.txt.bz2 List-Id: 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 void foo (T t); // #1 template void foo (X 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' like this. foo(X 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' from foo #2 and put into foo #1: foo(T x); // #1, where x of is any type X You can duduce T = X 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 void foo (T x); template void foo (X 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