This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1617: partial ordering of function templates



>Number:         1617
>Category:       c++
>Synopsis:       partial ordering of function templates
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 11 05:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Nathan
>Release:        cvs 20010111
>Organization:
>Environment:

>Description:
current/deduce.ii:6: call of overloaded `Foo(int*&)' is ambiguous
current/deduce.ii:1: candidates are: void Foo(T*) [with T = int]
current/deduce.ii:2:                 void Foo(T&) [with T = int*]

but I think the first choice is more specialized than the second. 14.5.5.2
tells us to take each choice in turn, synthesize a unique type for each
template type parameter into the function's parameter list and then try
type deduction using the other choice. The transformed template is at least
as specialized as the other if deduction succeeds and the deduced parameter
types are an exact match. In this case that gives us, with a unique type
called 'X'

a: Foo (T *) -> Foo (X *), using Foo (T &) deduce T to be X *, deduction succeeds.
b: Foo (T &) -> Foo (X &), using Foo (T *) deduction fails

so b is less specialized than a, and void Foo(T*) [with T = int] should
be selected

see http://gcc.gnu.org/ml/gcc-bugs/2001-01/msg00233.html
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="spec.ii"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="spec.ii"

dGVtcGxhdGUgPHR5cGVuYW1lIFQ+IHZvaWQgRm9vIChUICopOwp0ZW1wbGF0ZSA8dHlwZW5hbWUg
VD4gdm9pZCBGb28gKFQgJik7Cgp2b2lkIEJheiAoaW50ICpwdHIpCnsKICBGb28gKHB0cik7Cn0K

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]