| 1 |
// PR c++/47453 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
// invalid |
| 5 |
int a({0}); // { dg-error "" } |
| 6 |
|
| 7 |
// invalid |
| 8 |
int const &b({0}); // { dg-error "" } |
| 9 |
|
| 10 |
// invalid |
| 11 |
struct A1 { int a[2]; A1(); }; |
| 12 |
A1::A1():a({1, 2}) { } // { dg-error "" } |
| 13 |
|
| 14 |
struct A { explicit A(int, int); A(int, long); }; |
| 15 |
|
| 16 |
// invalid |
| 17 |
A c({1, 2}); // { dg-error "" } |
| 18 |
|
| 19 |
// valid (by copy constructor). |
| 20 |
A d({1, 2L}); |
| 21 |
|
| 22 |
// valid |
| 23 |
A e{1, 2}; |
| 24 |
|
| 25 |
#include <initializer_list> |
| 26 |
|
| 27 |
struct B { |
| 28 |
template<typename ...T> |
| 29 |
B(std::initializer_list<int>, T ...); |
| 30 |
}; |
| 31 |
|
| 32 |
// invalid (the first phase only considers init-list ctors) |
| 33 |
// (for the second phase, no constructor is viable) |
| 34 |
B f{1, 2, 3}; // { dg-error "" } |
| 35 |
|
| 36 |
// valid (T deduced to <>). |
| 37 |
B g({1, 2, 3}); |