FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p789a.C
blobb90cc7691a13f6c0c58d16e2bcefc52bbecaaf17
1 // global and local multidimensional array objects are not getting
2 // constructors called on any dimension, other than the first.  Also,
3 // the destructors are not being called.  Seems odd, they probably
4 // used to work. :-(
5 // prms-id: 789
7 extern "C" int printf (const char *, ...);
8 struct foo
10   static int count;
11   void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); }
12   int x;
13   foo () {
14     x = count++;
15     printf("this %d = %x\n", x, (void *)this);
16   }
17   virtual ~foo () {
18     printf("this %d = %x\n", x, (void *)this);
19     --count;
20   }
22 int foo::count;
25 int main ()
27   {
28     foo array[3][3];
29     for (int i = 0; i < 3; i++)
30       {
31         for (int j = 0; j < 3; j++)
32           {
33             printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]);
34           }
35       }
36       // The count should be nine, if not, fail the test.
37       if (foo::count != 9)
38         return 1;
39   }
40   if (foo::count != 0)
41     return 1;
42   return 0;