2014-01-30 Alangi Derick <alangiderick@gmail.com>
[official-gcc.git] / gcc / testsuite / g++.dg / pr57878.C
blob0a21ef53b1064a2cb9dbb687d40db11e82a813b8
1 /* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
2 /* { dg-options "-O2 -fno-omit-frame-pointer -fPIC -std=gnu++11" } */
4 typedef int int32;
5 typedef long long int64;
6 typedef unsigned int uint32;
7 typedef unsigned long long uint64;
8 namespace std {
9   typedef __SIZE_TYPE__ size_t;
10   template<class _CharT>
11   struct char_traits;
12   template<typename _Tp>
13   inline _Tp* __addressof(_Tp& __r) noexcept {
14     return reinterpret_cast<_Tp*> (&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
15   }
16   template<typename _Tp>
17   struct remove_reference {
18     typedef _Tp type;
19   };
20   template<typename _Tp>
21   constexpr _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) noexcept {
22     return static_cast<_Tp&&>(__t);
23   }
25 typedef __SIZE_TYPE__ size_t;
26 extern "C++" {
27   inline void* operator new(std::size_t, void* __p) noexcept {
28     return __p;
29   }
31 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
32   template<typename _Tp>
33     class new_allocator {
34   public:
35     typedef size_t size_type;
36     typedef _Tp* pointer;
37   };
39 namespace std {
40   template<typename _Tp>
41   using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
42   template<typename _Tp>
43   class allocator
44     : public __allocator_base<_Tp> {
45   public:
46     typedef size_t size_type;
47     template<typename _Tp1>
48     struct rebind {
49       typedef allocator<_Tp1> other;
50     };
51   };
53 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
54   template<typename _CharT, typename _Traits, typename _Alloc>
55     class __sso_string_base;
56   template<typename _CharT, typename _Traits = std::char_traits<_CharT>, typename _Alloc = std::allocator<_CharT>, template <typename, typename, typename> class _Base = __sso_string_base>
57     class __versa_string;
58   template<typename _CharT, typename _Traits, typename _Alloc>
59     struct __vstring_utility {
60     typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
61     template<typename _Alloc1>
62     struct _Alloc_hider
63       : public _Alloc1 {
64       _Alloc_hider(const _Alloc1& __a, _CharT* __ptr)
65   : _Alloc1(__a), _M_p(__ptr) {
66       }
67       _CharT* _M_p;
68     };
69   };
70   template<typename _CharT, typename _Traits, typename _Alloc>
71     class __sso_string_base
72       : protected __vstring_utility<_CharT, _Traits, _Alloc> {
73     typedef __vstring_utility<_CharT, _Traits, _Alloc> _Util_Base;
74     typedef typename _Util_Base::_CharT_alloc_type _CharT_alloc_type;
75     typedef typename _CharT_alloc_type::size_type size_type;
76   private:
77     typename _Util_Base::template _Alloc_hider<_CharT_alloc_type>
78     _M_dataplus;
79     size_type _M_string_length;
80     enum {
81       _S_local_capacity = 15 };
82     union {
83       _CharT _M_local_data[_S_local_capacity + 1];
84     };
85     template<typename _InIterator>
86     void _M_construct(_InIterator __beg, _InIterator __end);
87   public:
88     size_type _M_max_size() const;
89     _CharT* _M_data() const {
90       return _M_dataplus._M_p;
91     }
92     size_type _M_length() const {
93       return _M_string_length;
94     }
95     __sso_string_base(const __sso_string_base& __rcs);
96     const _CharT_alloc_type& _M_get_allocator() const {
97     }
98   };
99   template<typename _CharT, typename _Traits, typename _Alloc>
100     __sso_string_base<_CharT, _Traits, _Alloc>:: __sso_string_base(const __sso_string_base& __rcs)
101     : _M_dataplus(__rcs._M_get_allocator(), _M_local_data) {
102     _M_construct(__rcs._M_data(), __rcs._M_data() + __rcs._M_length());
103   }
104   template<typename _CharT, typename _Traits, typename _Alloc, template <typename, typename, typename> class _Base>
105     class __versa_string
106       : private _Base<_CharT, _Traits, _Alloc> {
107   };
109 template<typename _CharT, typename _Traits = std::char_traits<_CharT>, typename _Alloc = std::allocator<_CharT> >
110 class basic_string
111   : public __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc> {
113 typedef basic_string<char> string;
114 namespace std __attribute__ ((__visibility__ ("default"))) {
115   template<typename _Alloc, typename _Tp>
116     class __alloctr_rebind_helper {
117   public:
118     static const bool __value = true;
119   };
120   template<typename _Alloc, typename _Tp, bool = __alloctr_rebind_helper<_Alloc, _Tp>::__value>
121     struct __alloctr_rebind;
122   template<typename _Alloc, typename _Tp> struct __alloctr_rebind<_Alloc, _Tp, true>
123   {
124     typedef typename _Alloc::template rebind<_Tp>::other __type;
125   };
126   template<typename _Alloc>
127     struct allocator_traits {
128   private:
129     template<typename _Tp>
130     static typename _Tp::pointer _S_pointer_helper(_Tp*);
131     typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;
132   public:
133     typedef __pointer pointer;
134     template<typename _Tp>
135     using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;
136   };
138 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
139   template<typename _Alloc> struct __alloc_traits
140     : std::allocator_traits<_Alloc>
141   {
142     typedef std::allocator_traits<_Alloc> _Base_type;
143     template<typename _Tp>
144     struct rebind {
145       typedef typename _Base_type::template rebind_alloc<_Tp>
146       other;
147     };
148   };
150 namespace std __attribute__ ((__visibility__ ("default"))) {
151   template<typename _T1, typename... _Args>
152     inline void _Construct(_T1* __p, _Args&&... __args) {
153     ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...);
154   }
155   template<typename _Tp, typename _Alloc>
156     struct _Vector_base {
157     typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type;
158     typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer pointer;
159     struct _Vector_impl
160       : public _Tp_alloc_type {
161       pointer _M_start;
162       pointer _M_finish;
163     };
164   public:
165     _Vector_impl _M_impl;
166   };
167   template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
168     class vector
169       : protected _Vector_base<_Tp, _Alloc> {
170     typedef _Vector_base<_Tp, _Alloc> _Base;
171   public:
172     typedef _Tp value_type;
173     typedef typename _Base::pointer pointer;
174     typedef size_t size_type;
175     size_type size() const;
176     void push_back(const value_type& __x) {
177       _M_emplace_back_aux(__x);
178     }
179     template<typename... _Args>
180     void _M_emplace_back_aux(_Args&&... __args);
181     size_type _M_check_len();
182   };
183   template<typename _Tp, typename _Alloc> template<typename... _Args>
184     void vector<_Tp, _Alloc>:: _M_emplace_back_aux(_Args&&... __args) {
185     const size_type __len = _M_check_len();
186     pointer __new_start(static_cast<pointer>(::operator new(__len * sizeof(_Tp))));
187     pointer __new_temp(__new_start + size());
188     ::new((void *)__new_temp) _Tp(std::forward<_Args>(__args)...);
189     pointer __cur = __new_start;
190     pointer __first = this->_M_impl._M_start;
191     pointer __last = this->_M_impl._M_finish;
192     for (;
193          __first != __last;
194          ++__first, ++__cur) std::_Construct(std::__addressof(*__cur), *__first);
195   }
197 using std::vector;
198 class DL {
199 public:
200   struct ChunkId {
201     int64 disk_id;
202     uint64 handle;
203     uint64 version;
204     string capability;
205     ChunkId();
206   };
207   struct ChunkInfo {
208     ChunkId id;
209     uint64 mtime;
210     uint32 length;
211     int32 space_used;
212   };
214 class FDB {
215   void CollectChunk(const DL::ChunkInfo& chunk, const int& location);
216 private:
217   struct ChunkData {
218     int location;
219     DL::ChunkInfo chunk_info;
220   };
221   vector<ChunkData> chunk_data_;
223 void FDB::CollectChunk(const DL::ChunkInfo& chunk, const int& location) {
224   ChunkData chunk_data;
225   chunk_data_.push_back( chunk_data);