Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.pt/spec40.C

raw
1 // { dg-do compile }
2 // Copyright (C) 2000 Free Software Foundation, Inc.
3 // Contributed by Nathan Sidwell 12 Feb 2001 <[email protected]>
4
5 // More from bug 1617. The resolution of DR 214 implies that the below
6 // call to Foo is ambiguous.
7 //
8 // The type transformation (on the function parameter of Foo) allowed
9 // in the context of partial ordering of the Foo template overloads is
10 // the following ([temp.deduct.partial]/5):
11 //
12 // Before the partial ordering is done, certain transformations
13 // are performed on the types used for partial ordering:
14 //
15 // - If P is a reference type, P is replaced by the type
16 // referred to.
17 //
18 // - If A is a reference type, A is replaced by the type
19 // referred to.
20 //
21 // It follows that we are not allowed to apply array-to-pointer
22 // decay conversion to the type of the function parameter
23 // 'char const (&)[I]'. So the two Foo specializations should
24 // be considered unrelated. Thus the partial ordering of the two
25 // Foo specializations should fail.
26
27 template <typename T> int Foo (T const *) {return 1;}
28 template <unsigned I> int Foo (char const (&)[I]) {return 2;}
29
30 int main ()
31 {
32 return Foo ("a") != 2; // { dg-error "call of overloaded \[^\n\r\]* is ambiguous" }
33 }