| 1 |
// { dg-do run } |
| 2 |
// Produces ICE 980519. |
| 3 |
// Test case from Dirk Engelmann <[email protected]> |
| 4 |
|
| 5 |
namespace vector { |
| 6 |
|
| 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 |
} |
| 15 |
|
| 16 |
} |
| 17 |
|
| 18 |
namespace matrix { |
| 19 |
|
| 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 |
} |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
int main(void) |
| 37 |
{ |
| 38 |
// sample |
| 39 |
double **m=matrix::alloc<double>(10,20); |
| 40 |
|
| 41 |
} |