namespace problem
Dirk Engelmann
Dirk.Engelmann@IWR.Uni-Heidelberg.De
Tue Dec 15 07:26:00 GMT 1998
Sorry ! This message was sent before with file attach.
I appended the attachment to the end of the message.
-----------------------------------------------------
Hi!
I've got a problem with namespace.
At the end of the message a simple sample for allocating memory
of a matrix and vector namespace is appended.
This works with MS Visual-C++ compiler and egcs v 2.91.57 on
windows.
But it doesn't work on linux taking the most current (?)
(Version 2.91.60) egcs-1.1.1.
The error message result is:
test.cc: In function `double ** alloc<double>(int, int)':
test.cc:41: instantiated from here
test.cc:27: Internal compiler error 980519.
Because there is no way (at least without a lot's of work) to
avoid this behaviour, it would be a great help if there are any
fixes or hints how to manage it.
It seems very strange to me that egcs works on Windows (95)
plattform but not on Linux. Are there any explanations ?
Or is there a patch ?
Thanks for any help!
Regards,
Dirk Engelmann
test.cc
===================================================
namespace vector {
// allocate memory for vector
template <class T>
inline T* alloc(const int aWidth)
{
// allocate memory
return new T[aWidth];
}
}
namespace matrix {
// allocate memory for matrix
template <class T>
T** alloc(const int aWidth,const int aHeight)
{
// allocate memory
T **mat = vector::alloc<T*>(aHeight);
T *data = vector::alloc<T> (aWidth*aHeight);
assert((mat!=NULL) && (data!=NULL));
// set pointer
for (int i=0; i<aHeight; i++)
mat[i] = &data[aWidth*i];
// ok
return mat;
}
}
main(void)
{
// sample
double **m=matrix::alloc<double>(10,20);
}
More information about the Gcc-bugs
mailing list