Merged revision 156805 into branch.
[official-gcc.git] / gcc / testsuite / g++.dg / other / crash-8.C
blobc260431d5ec587c1827013cbad67cc9540b9bf22
1 // Origin: PR c++/42797
2 // { dg-options "-g -O2 -std=c++0x" }
4 template<typename _Tp, _Tp __v>     struct integral_constant     {
5     static const _Tp value = __v;
6 };
8 template<typename _Tp>     _Tp declval();
10 template<typename _Tp, typename... _Args>
11 class __is_constructible_helper  {
14 template<typename _Tp, typename _Arg>
15 class __is_constructible_helper<_Tp, _Arg>  {
17     template<typename _Tp1, typename _Arg1>
18     static decltype(static_cast<_Tp1>(declval<_Arg1>()), char())  __test(int);
19 public:
20     static const bool __value = sizeof(__test<_Tp, _Arg>(0)) == 1;
23 template<typename _Tp, typename... _Args>
24 struct is_constructible     : public integral_constant<bool,__is_constructible_helper<_Tp, _Args...>::__value>     { };
26 template<bool, typename _Tp = void>
27 struct enable_if  { };
29 template<typename _Tp>
30 struct enable_if<true, _Tp>     {
31     typedef _Tp type;
34 template<class _T1, class _T2>     struct pair     {
35     _T1 first;
36     _T2 second;
38     template<class _U2, class = typename  enable_if<is_constructible<_T2, _U2&&>::value>::type>
39     pair(const _T1& __x, _U2&& __y)  : first(__x),
40                                        second(__y) { }
43 namespace __gnu_cxx {
44 template<typename _Tp>
45 class new_allocator     {
46 public:
47     new_allocator() throw() { }
48     new_allocator(const new_allocator&) throw() { }
52 template<typename _Tp>
53 class allocator: public __gnu_cxx::new_allocator<_Tp>     {
54 public:
56     template<typename _Tp1>
57     struct rebind  {
58         typedef allocator<_Tp1> other;
59     };
63 template<typename _Tp, typename _Alloc>     struct _Vector_base     {
64     typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
66     struct _Vector_impl       : public _Tp_alloc_type   {
67         _Vector_impl()
68         { }
69     };
70 public:
72     _Vector_impl _M_impl;
75 template<typename _Tp, typename _Alloc = allocator<_Tp> >
76 class vector : protected _Vector_base<_Tp, _Alloc> {
77     typedef _Alloc allocator_type;
78 public:
79     vector()       { }
80     explicit       vector(int, const allocator_type& __a = allocator_type())
81     {
82     }
86 template <typename _Key, typename _Tp>
87 class map {
88     typedef _Key key_type;
89     typedef _Tp mapped_type;
90     typedef pair<const _Key, _Tp> value_type;
91 public:
93     void insert(const value_type& __x)
94     {
95     }
97     mapped_type&       operator[](const key_type& __k)       {
98         insert(value_type(__k, mapped_type()));
99     }
103 struct Foo {
104     Foo() {}      template<typename Tp>     Foo(Tp *p) {} };
105 void foo() {
106     map <int, vector<Foo>> the_map;
107     the_map[1] = vector<Foo>();