1 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx14_17 -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx17 -fexceptions -fcxx-exceptions -pedantic-errors
5 
6 namespace dr1512 { // dr1512: 4
f(char * p)7   void f(char *p) {
8     if (p > 0) {} // expected-error {{ordered comparison between pointer and zero}}
9 #if __cplusplus >= 201103L
10     if (p > nullptr) {} // expected-error {{invalid operands}}
11 #endif
12   }
g(int ** x,const int ** y)13   bool g(int **x, const int **y) {
14     return x < y;
15   }
16 
17   template<typename T> T val();
18 
composite_pointer_type_is_base()19   template<typename A, typename B, typename C> void composite_pointer_type_is_base() {
20     typedef __typeof(true ? val<A>() : val<B>()) type;
21     typedef C type;
22 
23     typedef __typeof(val<A>() == val<B>()) cmp;
24     typedef __typeof(val<A>() != val<B>()) cmp;
25     typedef bool cmp;
26   }
27 
composite_pointer_type_is_ord()28   template<typename A, typename B, typename C> void composite_pointer_type_is_ord() {
29     composite_pointer_type_is_base<A, B, C>();
30 
31     typedef __typeof(val<A>() < val<B>()) cmp;  // cxx17-warning 2 {{ordered comparison of function pointers}}
32     typedef __typeof(val<A>() <= val<B>()) cmp; // cxx17-warning 2 {{ordered comparison of function pointers}}
33     typedef __typeof(val<A>() > val<B>()) cmp;  // cxx17-warning 2 {{ordered comparison of function pointers}}
34     typedef __typeof(val<A>() >= val<B>()) cmp; // cxx17-warning 2 {{ordered comparison of function pointers}}
35     typedef bool cmp;
36   }
37 
38   template <typename A, typename B, typename C>
composite_pointer_type_is_unord(int=0)39   void composite_pointer_type_is_unord(int = 0) {
40     composite_pointer_type_is_base<A, B, C>();
41   }
42   template <typename A, typename B, typename C>
43   void composite_pointer_type_is_unord(__typeof(val<A>() < val<B>()) * = 0);
44   template <typename A, typename B, typename C>
45   void composite_pointer_type_is_unord(__typeof(val<A>() <= val<B>()) * = 0);
46   template <typename A, typename B, typename C>
47   void composite_pointer_type_is_unord(__typeof(val<A>() > val<B>()) * = 0);
48   template <typename A, typename B, typename C>
49   void composite_pointer_type_is_unord(__typeof(val<A>() >= val<B>()) * = 0);
50 
51   // A call to this is ambiguous if a composite pointer type exists.
52   template<typename A, typename B>
53   void no_composite_pointer_type(__typeof((true ? val<A>() : val<B>()), void()) * = 0);
54   template<typename A, typename B> void no_composite_pointer_type(int = 0);
55 
56   struct A {};
57   struct B : A {};
58   struct C {};
59 
test()60   void test() {
61 #if __cplusplus >= 201103L
62     using nullptr_t = decltype(nullptr);
63     composite_pointer_type_is_unord<nullptr_t, nullptr_t, nullptr_t>();
64     no_composite_pointer_type<nullptr_t, int>();
65 
66     composite_pointer_type_is_unord<nullptr_t, const char**, const char**>();
67     composite_pointer_type_is_unord<const char**, nullptr_t, const char**>();
68 #endif
69 
70     composite_pointer_type_is_ord<const int *, volatile void *, const volatile void*>();
71     composite_pointer_type_is_ord<const void *, volatile int *, const volatile void*>();
72 
73     composite_pointer_type_is_ord<const A*, volatile B*, const volatile A*>();
74     composite_pointer_type_is_ord<const B*, volatile A*, const volatile A*>();
75 
76     composite_pointer_type_is_unord<const int *A::*, volatile int *B::*, const volatile int *const B::*>();
77     composite_pointer_type_is_unord<const int *B::*, volatile int *A::*, const volatile int *const B::*>();
78     no_composite_pointer_type<int (A::*)(), int (C::*)()>();
79     no_composite_pointer_type<const int (A::*)(), volatile int (C::*)()>();
80 
81 #if __cplusplus > 201402
82     composite_pointer_type_is_ord<int (*)() noexcept, int (*)(), int (*)()>(); // expected-note {{requested here}}
83     composite_pointer_type_is_ord<int (*)(), int (*)() noexcept, int (*)()>(); // expected-note {{requested here}}
84     composite_pointer_type_is_unord<int (A::*)() noexcept, int (A::*)(), int (A::*)()>();
85     composite_pointer_type_is_unord<int (A::*)(), int (A::*)() noexcept, int (A::*)()>();
86     // FIXME: This looks like a standard defect; these should probably all have type 'int (B::*)()'.
87     composite_pointer_type_is_unord<int (B::*)(), int (A::*)() noexcept, int (B::*)()>();
88     composite_pointer_type_is_unord<int (A::*)() noexcept, int (B::*)(), int (B::*)()>();
89     composite_pointer_type_is_unord<int (B::*)() noexcept, int (A::*)(), int (B::*)()>();
90     composite_pointer_type_is_unord<int (A::*)(), int (B::*)() noexcept, int (B::*)()>();
91 
92     // FIXME: It would be reasonable to permit these, with a common type of 'int (*const *)()'.
93     no_composite_pointer_type<int (**)() noexcept, int (**)()>();
94     no_composite_pointer_type<int (**)(), int (**)() noexcept>();
95 
96     // FIXME: It would be reasonable to permit these, with a common type of 'int (A::*)()'.
97     no_composite_pointer_type<int (A::*)() const, int (A::*)()>();
98     no_composite_pointer_type<int (A::*)(), int (A::*)() const>();
99 
100     // FIXME: It would be reasonable to permit these, with a common type of
101     // 'int (A::*)() &' and 'int (A::*)() &&', respectively.
102     no_composite_pointer_type<int (A::*)() &, int (A::*)()>();
103     no_composite_pointer_type<int (A::*)(), int (A::*)() &>();
104     no_composite_pointer_type<int (A::*)() &&, int (A::*)()>();
105     no_composite_pointer_type<int (A::*)(), int (A::*)() &&>();
106 
107     no_composite_pointer_type<int (A::*)() &&, int (A::*)() &>();
108     no_composite_pointer_type<int (A::*)() &, int (A::*)() &&>();
109 
110     no_composite_pointer_type<int (C::*)(), int (A::*)() noexcept>();
111     no_composite_pointer_type<int (A::*)() noexcept, int (C::*)()>();
112 #endif
113   }
114 
115 #if __cplusplus >= 201103L
116   template<typename T> struct Wrap { operator T(); }; // expected-note 4{{converted to type 'std::nullptr_t'}} expected-note 4{{converted to type 'int *'}}
test_overload()117   void test_overload() {
118     using nullptr_t = decltype(nullptr);
119     void(Wrap<nullptr_t>() == Wrap<nullptr_t>());
120     void(Wrap<nullptr_t>() != Wrap<nullptr_t>());
121     void(Wrap<nullptr_t>() < Wrap<nullptr_t>()); // expected-error {{invalid operands}}
122     void(Wrap<nullptr_t>() > Wrap<nullptr_t>()); // expected-error {{invalid operands}}
123     void(Wrap<nullptr_t>() <= Wrap<nullptr_t>()); // expected-error {{invalid operands}}
124     void(Wrap<nullptr_t>() >= Wrap<nullptr_t>()); // expected-error {{invalid operands}}
125 
126     // Under dr1213, this is ill-formed: we select the builtin operator<(int*, int*)
127     // but then only convert as far as 'nullptr_t', which we then can't convert to 'int*'.
128     void(Wrap<nullptr_t>() == Wrap<int*>());
129     void(Wrap<nullptr_t>() != Wrap<int*>());
130     void(Wrap<nullptr_t>() < Wrap<int*>()); // expected-error {{invalid operands to binary expression ('Wrap<nullptr_t>' (aka 'Wrap<std::nullptr_t>') and 'Wrap<int *>')}}
131     void(Wrap<nullptr_t>() > Wrap<int*>()); // expected-error {{invalid operands}}
132     void(Wrap<nullptr_t>() <= Wrap<int*>()); // expected-error {{invalid operands}}
133     void(Wrap<nullptr_t>() >= Wrap<int*>()); // expected-error {{invalid operands}}
134   }
135 #endif
136 }
137 
138 namespace dr1514 { // dr1514: 11
139 #if __cplusplus >= 201103L
140   struct S {
141     enum E : int {}; // expected-note {{previous}}
142     enum E : int {}; // expected-error {{redefinition}}
143   };
144   S::E se; // OK, complete type, not zero-width bitfield.
145 
146   // The behavior in other contexts is superseded by DR1966.
147 #endif
148 }
149 
150 namespace dr1518 { // dr1518: 4
151 #if __cplusplus >= 201103L
152 struct Z0 { // expected-note 0+ {{candidate}}
153   explicit Z0() = default; // expected-note 0+ {{here}}
154 };
155 struct Z { // expected-note 0+ {{candidate}}
156   explicit Z(); // expected-note 0+ {{here}}
157   explicit Z(int); // expected-note {{not a candidate}}
158   explicit Z(int, int); // expected-note 0+ {{here}}
159 };
160 template <class T> int Eat(T); // expected-note 0+ {{candidate}}
161 Z0 a;
162 Z0 b{};
163 Z0 c = {}; // expected-error {{explicit in copy-initialization}}
164 int i = Eat<Z0>({}); // expected-error {{no matching function for call to 'Eat'}}
165 
166 Z c2 = {}; // expected-error {{explicit in copy-initialization}}
167 int i2 = Eat<Z>({}); // expected-error {{no matching function for call to 'Eat'}}
168 Z a1 = 1; // expected-error {{no viable conversion}}
169 Z a3 = Z(1);
170 Z a2(1);
171 Z *p = new Z(1);
172 Z a4 = (Z)1;
173 Z a5 = static_cast<Z>(1);
174 Z a6 = {4, 3}; // expected-error {{explicit in copy-initialization}}
175 
176 struct UserProvidedBaseCtor { // expected-note 0+ {{candidate}}
UserProvidedBaseCtordr1518::UserProvidedBaseCtor177   UserProvidedBaseCtor() {}
178 };
179 struct DoesntInheritCtor : UserProvidedBaseCtor { // expected-note 0+ {{candidate}}
180   int x;
181 };
182 DoesntInheritCtor I{{}, 42};
183 #if __cplusplus <= 201402L
184 // expected-error@-2 {{no matching constructor}}
185 #endif
186 
187 struct BaseCtor { BaseCtor() = default; }; // expected-note 0+ {{candidate}}
188 struct InheritsCtor : BaseCtor { // expected-note 1+ {{candidate}}
189   using BaseCtor::BaseCtor;      // expected-note 2 {{inherited here}}
190   int x;
191 };
192 InheritsCtor II = {{}, 42}; // expected-error {{no matching constructor}}
193 
194 namespace std_example {
195   struct A {
196     explicit A() = default; // expected-note 2{{declared here}}
197   };
198 
199   struct B : A {
200     explicit B() = default; // expected-note 2{{declared here}}
201   };
202 
203   struct C {
204     explicit C(); // expected-note 2{{declared here}}
205   };
206 
207   struct D : A {
208     C c;
209     explicit D() = default; // expected-note 2{{declared here}}
210   };
211 
f()212   template <typename T> void f() {
213     T t; // ok
214     T u{}; // ok
215     T v = {}; // expected-error 4{{explicit}}
216   }
g()217   template <typename T> void g() {
218     void x(T t); // expected-note 4{{parameter}}
219     x({}); // expected-error 4{{explicit}}
220   }
221 
test()222   void test() {
223     f<A>(); // expected-note {{instantiation of}}
224     f<B>(); // expected-note {{instantiation of}}
225     f<C>(); // expected-note {{instantiation of}}
226     f<D>(); // expected-note {{instantiation of}}
227     g<A>(); // expected-note {{instantiation of}}
228     g<B>(); // expected-note {{instantiation of}}
229     g<C>(); // expected-note {{instantiation of}}
230     g<D>(); // expected-note {{instantiation of}}
231   }
232 }
233 #endif                      // __cplusplus >= 201103L
234 }
235 
236 namespace dr1550 { // dr1550: yes
f(bool b,int n)237   int f(bool b, int n) {
238     return (b ? (throw 0) : n) + (b ? n : (throw 0));
239   }
240 }
241 
242 namespace dr1558 { // dr1558: 12
243 #if __cplusplus >= 201103L
244   template<class T, class...> using first_of = T;
245   template<class T> first_of<void, typename T::type> f(int); // expected-note {{'int' cannot be used prior to '::'}}
246   template<class T> void f(...) = delete; // expected-note {{deleted}}
247 
248   struct X { typedef void type; };
test()249   void test() {
250     f<X>(0);
251     f<int>(0); // expected-error {{deleted}}
252   }
253 #endif
254 }
255 
256 namespace dr1560 { // dr1560: 3.5
f(bool b,int n)257   void f(bool b, int n) {
258     (b ? throw 0 : n) = (b ? n : throw 0) = 0;
259   }
260   class X { X(const X&); };
261   const X &get();
262   const X &x = true ? get() : throw 0;
263 }
264 
265 namespace dr1563 { // dr1563: yes
266 #if __cplusplus >= 201103L
bar(double)267   double bar(double) { return 0.0; }
bar(float)268   float bar(float) { return 0.0f; }
269 
270   using fun = double(double);
271   fun &foo{bar}; // ok
272 #endif
273 }
274 
275 namespace dr1573 { // dr1573: 3.9
276 #if __cplusplus >= 201103L
277   // ellipsis is inherited (p0136r1 supersedes this part).
278   struct A { A(); A(int, char, ...); };
279   struct B : A { using A::A; };
280   B b(1, 'x', 4.0, "hello"); // ok
281 
282   // inherited constructor is effectively constexpr if the user-written constructor would be
Cdr1573::C283   struct C { C(); constexpr C(int) {} };
284   struct D : C { using C::C; };
285   constexpr D d = D(0); // ok
286   struct E : C { using C::C; A a; }; // expected-note {{non-literal type}}
287   constexpr E e = E(0); // expected-error {{non-literal type}}
288   // FIXME: This diagnostic is pretty bad; we should explain that the problem
289   // is that F::c would be initialized by a non-constexpr constructor.
290   struct F : C { using C::C; C c; }; // expected-note {{here}}
291   constexpr F f = F(0); // expected-error {{constant expression}} expected-note {{constructor inherited from base class 'C'}}
292 
293   // inherited constructor is effectively deleted if the user-written constructor would be
294   struct G { G(int); };
295   struct H : G { using G::G; G g; }; // expected-note {{constructor inherited by 'H' is implicitly deleted because field 'g' has no default constructor}}
296   H h(0); // expected-error {{constructor inherited by 'H' from base class 'G' is implicitly deleted}}
297 #endif
298 }
299 
300 #if __cplusplus >= 201103L
301 namespace std {
302   typedef decltype(sizeof(int)) size_t;
303 
304   // libc++'s implementation
305   template <class _E>
306   class initializer_list
307   {
308     const _E* __begin_;
309     size_t    __size_;
310 
initializer_list(const _E * __b,size_t __s)311     initializer_list(const _E* __b, size_t __s)
312     : __begin_(__b), __size_(__s) {}
313 
314   public:
315     typedef _E        value_type;
316     typedef const _E& reference;
317     typedef const _E& const_reference;
318     typedef size_t    size_type;
319 
320     typedef const _E* iterator;
321     typedef const _E* const_iterator;
322 
initializer_list()323     initializer_list() : __begin_(nullptr), __size_(0) {}
324 
size() const325     size_t    size()  const {return __size_;}
begin() const326     const _E* begin() const {return __begin_;}
end() const327     const _E* end()   const {return __begin_ + __size_;}
328   };
329 
330   template < class _T1, class _T2 > struct pair { _T2 second; };
331 
332   template<typename T> struct basic_string {
basic_stringstd::basic_string333     basic_string(const T* x) {}
~basic_stringstd::basic_string334     ~basic_string() {};
335   };
336   typedef basic_string<char> string;
337 
338 } // std
339 
340 namespace dr1579 { // dr1579: 3.9
341 template<class T>
342 struct GenericMoveOnly {
343   GenericMoveOnly();
344   template<class U> GenericMoveOnly(const GenericMoveOnly<U> &) = delete; // expected-note 5 {{marked deleted here}}
345   GenericMoveOnly(const int &) = delete; // expected-note 2 {{marked deleted here}}
346   template<class U> GenericMoveOnly(GenericMoveOnly<U> &&);
347   GenericMoveOnly(int &&);
348 };
349 
DR1579_Eligible(GenericMoveOnly<char> CharMO)350 GenericMoveOnly<float> DR1579_Eligible(GenericMoveOnly<char> CharMO) {
351   int i;
352   GenericMoveOnly<char> GMO;
353 
354   if (0)
355     return i;
356   else if (0)
357     return GMO;
358   else if (0)
359     return ((GMO));
360   else
361     return CharMO;
362 }
363 
364 GenericMoveOnly<char> GlobalMO;
365 
DR1579_Ineligible(int & AnInt,GenericMoveOnly<char> & CharMO)366 GenericMoveOnly<float> DR1579_Ineligible(int &AnInt,
367                                           GenericMoveOnly<char> &CharMO) {
368   static GenericMoveOnly<char> StaticMove;
369   extern GenericMoveOnly<char> ExternMove;
370 
371   if (0)
372     return AnInt; // expected-error{{invokes a deleted function}}
373   else if (0)
374     return GlobalMO; // expected-error{{invokes a deleted function}}
375   else if (0)
376     return StaticMove; // expected-error{{invokes a deleted function}}
377   else if (0)
378     return ExternMove; // expected-error{{invokes a deleted function}}
379   else if (0)
380     return AnInt; // expected-error{{invokes a deleted function}}
381   else
382     return CharMO; // expected-error{{invokes a deleted function}}
383 }
384 
385 auto DR1579_lambda_valid = [](GenericMoveOnly<float> mo) ->
__anon01a3dc820102(GenericMoveOnly<float> mo) 386   GenericMoveOnly<char> {
387   return mo;
388 };
389 
__anon01a3dc820202() 390 auto DR1579_lambda_invalid = []() -> GenericMoveOnly<char> {
391   static GenericMoveOnly<float> mo;
392   return mo; // expected-error{{invokes a deleted function}}
393 };
394 } // end namespace dr1579
395 
396 namespace dr1584 {
397   // Deducing function types from cv-qualified types
398   template<typename T> void f(const T *); // expected-note {{candidate template ignored}}
399   template<typename T> void g(T *, const T * = 0);
h(T *)400   template<typename T> void h(T *) { T::error; } // expected-error {{no members}}
401   template<typename T> void h(const T *);
i()402   void i() {
403     f(&i); // expected-error {{no matching function}}
404     g(&i);
405     h(&i); // expected-note {{here}}
406   }
407 }
408 
409 namespace dr1589 {   // dr1589: 3.7 c++11
410   // Ambiguous ranking of list-initialization sequences
411 
412   void f0(long, int=0);                 // Would makes selection of #0 ambiguous
413   void f0(long);                        // #0
414   void f0(std::initializer_list<int>);  // #00
g0()415   void g0() { f0({1L}); }               // chooses #00
416 
417   void f1(int, int=0);                    // Would make selection of #1 ambiguous
418   void f1(int);                           // #1
419   void f1(std::initializer_list<long>);   // #2
g1()420   void g1() { f1({42}); }                 // chooses #2
421 
422   void f2(std::pair<const char*, const char*>, int = 0); // Would makes selection of #3 ambiguous
423   void f2(std::pair<const char*, const char*>); // #3
424   void f2(std::initializer_list<std::string>);  // #4
g2()425   void g2() { f2({"foo","bar"}); }              // chooses #4
426 
427   namespace with_error {
428     void f0(long);                        // #0
429     void f0(std::initializer_list<int>);  // #00     expected-note {{candidate function}}
430     void f0(std::initializer_list<int>, int = 0); // expected-note {{candidate function}}
g0()431     void g0() { f0({1L}); }                 // expected-error{{call to 'f0' is ambiguous}}
432 
433     void f1(int);                           // #1
434     void f1(std::initializer_list<long>);   // #2     expected-note {{candidate function}}
435     void f1(std::initializer_list<long>, int = 0); // expected-note {{candidate function}}
g1()436     void g1() { f1({42}); }                 // expected-error{{call to 'f1' is ambiguous}}
437 
438     void f2(std::pair<const char*, const char*>); // #3
439     void f2(std::initializer_list<std::string>);  // #4      expected-note {{candidate function}}
440     void f2(std::initializer_list<std::string>, int = 0); // expected-note {{candidate function}}
g2()441     void g2() { f2({"foo","bar"}); }        // expected-error{{call to 'f2' is ambiguous}}
442   }
443 
444 } // dr1589
445 
446 namespace dr1591 {  //dr1591. Deducing array bound and element type from initializer list
447   template<class T, int N> int h(T const(&)[N]);
448   int X = h({1,2,3});              // T deduced to int, N deduced to 3
449 
450   template<class T> int j(T const(&)[3]);
451   int Y = j({42});                 // T deduced to int, array bound not considered
452 
453   struct Aggr { int i; int j; };
454   template<int N> int k(Aggr const(&)[N]); //expected-note{{not viable}}
455   int Y0 = k({1,2,3});              //expected-error{{no matching function}}
456   int Z = k({{1},{2},{3}});        // OK, N deduced to 3
457 
458   template<int M, int N> int m(int const(&)[M][N]);
459   int X0 = m({{1,2},{3,4}});        // M and N both deduced to 2
460 
461   template<class T, int N> int n(T const(&)[N], T);
462   int X1 = n({{1},{2},{3}},Aggr()); // OK, T is Aggr, N is 3
463 
464 
465   namespace check_multi_dim_arrays {
466     template<class T, int N, int M, int O> int ***f(const T (&a)[N][M][O]); //expected-note{{deduced conflicting values}}
467     template<class T, int N, int M> int **f(const T (&a)[N][M]); //expected-note{{couldn't infer}}
468 
469    template<class T, int N> int *f(const T (&a)[N]); //expected-note{{couldn't infer}}
470     int ***p3 = f({  {  {1,2}, {3, 4}  }, {  {5,6}, {7, 8}  }, {  {9,10}, {11, 12}  } });
471     int ***p33 = f({  {  {1,2}, {3, 4}  }, {  {5,6}, {7, 8}  }, {  {9,10}, {11, 12, 13}  } }); //expected-error{{no matching}}
472     int **p2 = f({  {1,2,3}, {3, 4, 5}  });
473     int **p22 = f({  {1,2}, {3, 4}  });
474     int *p1 = f({1, 2, 3});
475   }
476   namespace check_multi_dim_arrays_rref {
477     template<class T, int N, int M, int O> int ***f(T (&&a)[N][M][O]); //expected-note{{deduced conflicting values}}
478     template<class T, int N, int M> int **f(T (&&a)[N][M]); //expected-note{{couldn't infer}}
479 
480     template<class T, int N> int *f(T (&&a)[N]); //expected-note{{couldn't infer}}
481     int ***p3 = f({  {  {1,2}, {3, 4}  }, {  {5,6}, {7, 8}  }, {  {9,10}, {11, 12}  } });
482     int ***p33 = f({  {  {1,2}, {3, 4}  }, {  {5,6}, {7, 8}  }, {  {9,10}, {11, 12, 13}  } }); //expected-error{{no matching}}
483     int **p2 = f({  {1,2,3}, {3, 4, 5}  });
484     int **p22 = f({  {1,2}, {3, 4}  });
485     int *p1 = f({1, 2, 3});
486   }
487 
488   namespace check_arrays_of_init_list {
489     template<class T, int N> float *f(const std::initializer_list<T> (&)[N]);
490     template<class T, int N> double *f(const T(&)[N]);
491     double *p = f({1, 2, 3});
492     float *fp = f({{1}, {1, 2}, {1, 2, 3}});
493   }
494   namespace core_reflector_28543 {
495 
496     template<class T, int N> int *f(T (&&)[N]);  // #1
497     template<class T> char *f(std::initializer_list<T> &&);  //#2
498     template<class T, int N, int M> int **f(T (&&)[N][M]); //#3 expected-note{{candidate}}
499     template<class T, int N> char **f(std::initializer_list<T> (&&)[N]); //#4 expected-note{{candidate}}
500 
501     template<class T> short *f(T (&&)[2]);  //#5
502 
503     template<class T> using Arr = T[];
504 
505     char *pc = f({1, 2, 3}); // OK prefer #2 via 13.3.3.2 [over.ics.rank]
506     char *pc2 = f({1, 2}); // #2 also
507     int *pi = f(Arr<int>{1, 2, 3}); // OK prefer #1
508 
509     void *pv1 = f({ {1, 2, 3}, {4, 5, 6} }); // expected-error{{ambiguous}} btw 3 & 4
510     char **pcc = f({ {1}, {2, 3} }); // OK #4
511 
512     short *ps = f(Arr<int>{1, 2});  // OK #5
513   }
514 } // dr1591
515 
516 #endif
517