Rebase.
[official-gcc.git] / gcc / testsuite / g++.dg / init / for1.C
blob420e85cff6964b2cc85f77957dcf51ed1798b0aa
1 // PR c++/13865
2 // Bug: We were destroying 'a' before executing the loop.
4 // { dg-do run }
6 #include <stdio.h>
8 int i;
9 int r;
11 class A
13 public:
14   A() { printf("A ctor\n"); }
15   ~A()
16   {
17     printf("A dtor\n");
18     if (i != 2)
19       r = 1;
20   }
23 int main(int argc, char **argv)
25   for (A a; i < 2; ++i) {
26     printf("iteration %d\n", i);
27   }
29   return r;