Debian Codegraph @

gcc/testsuite/g++.dg/other/crash-8.C

raw
1 // Origin: PR c++/42797
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-g -O2" }
4
5 template<typename _Tp, _Tp __v> struct integral_constant {
6 static const _Tp value = __v;
7 };
8
9 template<typename _Tp> _Tp declval();
10
11 template<typename _Tp, typename... _Args>
12 class __is_constructible_helper {
13 };
14
15 template<typename _Tp, typename _Arg>
16 class __is_constructible_helper<_Tp, _Arg> {
17
18 template<typename _Tp1, typename _Arg1>
19 static decltype(static_cast<_Tp1>(declval<_Arg1>()), char()) __test(int);
20 public:
21 static const bool __value = sizeof(__test<_Tp, _Arg>(0)) == 1;
22 };
23
24 template<typename _Tp, typename... _Args>
25 struct is_constructible : public integral_constant<bool,__is_constructible_helper<_Tp, _Args...>::__value> { };
26
27 template<bool, typename _Tp = void>
28 struct enable_if { };
29
30 template<typename _Tp>
31 struct enable_if<true, _Tp> {
32 typedef _Tp type;
33 };
34
35 template<class _T1, class _T2> struct pair {
36 _T1 first;
37 _T2 second;
38
39 template<class _U2, class = typename enable_if<is_constructible<_T2, _U2&&>::value>::type>
40 pair(const _T1& __x, _U2&& __y) : first(__x),
41 second(__y) { }
42 };
43
44 namespace __gnu_cxx {
45 template<typename _Tp>
46 class new_allocator {
47 public:
48 new_allocator() throw() { }
49 new_allocator(const new_allocator&) throw() { }
50 };
51 }
52
53 template<typename _Tp>
54 class allocator: public __gnu_cxx::new_allocator<_Tp> {
55 public:
56
57 template<typename _Tp1>
58 struct rebind {
59 typedef allocator<_Tp1> other;
60 };
61 };
62
63
64 template<typename _Tp, typename _Alloc> struct _Vector_base {
65 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
66
67 struct _Vector_impl : public _Tp_alloc_type {
68 _Vector_impl()
69 { }
70 };
71 public:
72
73 _Vector_impl _M_impl;
74 };
75
76 template<typename _Tp, typename _Alloc = allocator<_Tp> >
77 class vector : protected _Vector_base<_Tp, _Alloc> {
78 typedef _Alloc allocator_type;
79 public:
80 vector() { }
81 explicit vector(int, const allocator_type& __a = allocator_type())
82 {
83 }
84 };
85
86
87 template <typename _Key, typename _Tp>
88 class map {
89 typedef _Key key_type;
90 typedef _Tp mapped_type;
91 typedef pair<const _Key, _Tp> value_type;
92 public:
93
94 void insert(const value_type& __x)
95 {
96 }
97
98 mapped_type& operator[](const key_type& __k) {
99 insert(value_type(__k, mapped_type()));
100 static mapped_type a;
101 return a;
102 }
103
104 };
105
106 struct Foo {
107 Foo() {} template<typename Tp> Foo(Tp *p) {} };
108 void foo() {
109 map <int, vector<Foo>> the_map;
110 the_map[1] = vector<Foo>();
111 }
112