1// { dg-do assemble  }
2// GROUPS passed operators
3#include <iostream>
4
5//
6// ffrees space allocated for N-D array
7//
8
9template <class T>
10void ffree(long rows, T** array)
11{
12for( long i = 0; i < rows; i++ )
13  delete [] array[i];                   // delete row
14delete [] array;                        // delete outer array
15}
16
17template <class T>
18T* allocate1d(long size, T*& array)
19{
20return array = new T[size];
21}
22
23template <class T>
24T** allocate2d(long d1, long d2, T**& array)
25{
26if( allocate1d(d1, array) != 0 )
27  {
28  for( long i = 0; i < d1; i++ )
29    {
30    if( allocate1d(d2, array[i]) == 0 )
31      {
32      ffree(i,array);
33      return array;
34      }
35    }
36  }
37return array;
38}
39
40int main()
41{
42long d1 = 3, d2 = 4;
43class foo
44{
45public:
46foo() {std::cout << "foo created" << std::endl; }
47
48~foo() {std::cout << "foo deleted" << std::endl; }
49};
50
51foo **f2;
52allocate2d(d1, d2, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
53ffree(d1, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
54
55}
56