2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.ns / template9.C
blob3914746d71e5dbbc9d96f8678bfaa47c66093aaf
1 // { dg-do run  }
2 // Produces ICE 980519.
3 // Test case from Dirk Engelmann <Dirk.Engelmann@IWR.Uni-Heidelberg.De>
5 namespace vector {
7   // allocate memory for vector
8         
9         template <class T>
10         inline T* alloc(const int aWidth)
11         {
12                 // allocate memory
13                 return new T[aWidth];
14         }
18 namespace matrix {
20   // allocate memory for matrix
21         template <class T>
22         T** alloc(const int aWidth,const int aHeight)
23         {
24                 // allocate memory
25                 T **mat = vector::alloc<T*>(aHeight);
26                 T *data = vector::alloc<T> (aWidth*aHeight);
27                 // set pointer
28                 for (int i=0; i<aHeight; i++)
29                         mat[i] = &data[aWidth*i];
30                 // ok
31                 return mat;
32         }
36 int main(void)
38   // sample
39   double **m=matrix::alloc<double>(10,20);