Mail Archives: djgpp/1997/02/03/06:51:53
>From: "r. v. paasen" <R DOT L DOT F DOT v DOT Paasen AT stud DOT tue DOT nl>
>2) gcc produces a warning (NOT related to 1) that I don't understand:
> 'control reaches end of non-void function `Matrix::operator ()(int,
>int) const'
> I included the info for this warning at the end of this message.
> Could someone explain what the warning means, and how it can be
>resolved?
>Richard.
> float& operator()(int r, int c) const
> {
> #ifdef RANGECHECK
> if (!matrix) fail("Trying to index a non-matrix"); // matrix is an
>array
> else
> if (r<0 || r>=rows || c<0 || c>=cols) fail("Trying to index
>matrix out of range");
> else
> #endif
> return matrix[r*cols+c]; // this is line 87 with the warning
> }
If RANGECHECK is defined then the function calls fail() - which you and I
know cannot return but which the compiler doesnt - hence if you get an error
the compiler thinks implicit return (without a value) is possible
Paul
------------------------------------------------------------------------
Paul Dixon Email: p DOT dixon AT ic DOT ac DOT uk
Software Engineer tel: +44 (171) 725 1098
Academic Dept of Paediatrics fax: +44 (171) 725 6284
St Mary's Hospital Medical School
(a constituent college of
Imperial College of Science, Technology & Medicine)
Norfolk Place, London W2 1PG, UK
------------------------------------------------------------------------
- Raw text -