2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr48695.C
blob2f2953d9999c418996e0d050e97d4b6490a71ea1
1 // { dg-do run }
2 /* { dg-options "-fcheck-new" } */
4 typedef __SIZE_TYPE__ size_t;
6 inline void *operator new (size_t, void *__p) throw() { return __p; }
8 struct _Vector_impl
10   int *_M_start;
11   int *_M_finish;
12   _Vector_impl () :_M_start (0), _M_finish (0) {}
15 struct vector
17   _Vector_impl _M_impl;
18   int *_M_allocate (size_t __n)
19   {
20     return __n != 0 ? new int[__n] : 0;
21   }
22   void push_back ()
23   {
24     new (this->_M_impl._M_finish) int ();
25     this->_M_impl._M_finish =
26       this->_M_allocate (this->_M_impl._M_finish - this->_M_impl._M_start) + 1;
27   }
30 int
31 main ()
33   for (int i = 0; i <= 1; i++)
34     for (int j = 0; j <= 1; j++)
35       {
36         vector a[2];
37         a[i].push_back ();
38       }