Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Paul N. Hilfinger
Tue, 27 Oct 1992 22:58
gcc-2.2.2 handling of C++ const member functions in templates
Author: Paul N. Hilfinger
Date: Tue, 27 Oct 1992 22:58
Date: Tue, 27 Oct 1992 22:58
79 lines
2602 bytes
2602 bytes
The attached C++ file as input to gcc-2.2.2 causes an error message
that I believe to be incorrect. Session transcript:
----------------------------------------------------------------------
tully 421% gcc -c -v templates-a.C
Reading specs from /usr/sww/lib/gcc-lib/sun4/2.2.2/specs
gcc version 2.2.2
/usr/sww/lib/gcc-lib/sun4/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix templates-a.C /usr/tmp/cca16197.i
GNU CPP version 2.2.2 (sparc)
/usr/sww/lib/gcc-lib/sun4/2.2.2/cc1plus /usr/tmp/cca16197.i -quiet -dumpbase templates-a.cc -version -o /usr/tmp/cca16197.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
templates.C: In function `int main ()':
templates.C:19: template for method `colsOf' doesn't match any in class `Array2D<double>'
templates.C:19: template for method `rowsOf' doesn't match any in class `Array2D<double>'
----------------------------------------------------------------------
The two error messages regarding colsOf and rowsOf seem to be wrong.
If the "const" qualifier is removed from these member functions, no
message results.
Source file templates-a.C (pre-processed):
----------------------------------cut here------------------------------------
# 1 "templates.C"
template<class T> class Array2D {
public:
Array2D(int m, int n);
T& operator()(int i, int j);
int rowsOf() const ;
int colsOf() const ;
private:
T* data;
int M, N;
};
template<class T> Array2D<T>::Array2D(int m, int n) :
M(m), N(n), data(new T[m*n])
{}
template<class T> T& Array2D<T>::operator()(int i, int j)
{
return data[i * N + j];
}
template<class T> int Array2D<T>::rowsOf() const
{
return M;
}
template<class T> int Array2D<T>::colsOf() const
{
return N;
}
int main()
{
Array2D<double> A(2, 3);
for (int i = 0; i < A.rowsOf(); i += 1)
for (int j = 0; j < A.colsOf(); i += 1)
A(i,j) = i / 3.0 + j / 17.0;
return 0;
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads