OSDN Git Service

up
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.jason / dtor5.C
1 // PRMS Id: 5286
2 // Bug: g++ forgets side-effects of object in call to nonexistent destructor.
3
4 #include <new>
5
6 int r;
7
8 template <class T> struct A {
9   T *p;
10   int i;
11   A() { i = 0; p = (T*) new char[sizeof (T)]; new (p + i++) T; }
12   ~A() { p[--i].~T(); r = i; }
13 };
14
15 main()
16 {
17   { A<int> a; }
18
19   int* p = (int*) new char[sizeof (int)];
20   new (p + r++) int;
21   p[--r].~int();
22   
23   return r;
24 }