Skip to content

#282 Constness of BCRSMatrix ignored

Metadata

Property Value
Reported by Oliver Sander (oliver.sander@tu-dresden.de)
Reported at Apr 10, 2007 08:29
Type Bug Report
Version Git (pre2.4) [autotools]
Operating System Unspecified / All
Closed by Markus Blatt (markus@dr-blatt.de)
Closed at Apr 19, 2007 15:34
Closed in version Unknown
Resolution Fixed
Comment Fixed in recivisions 282 and 283

Description

Consider the following test case:

#include <config.h> #include <dune/common/fmatrix.hh> #include <dune/istl/bcrsmatrix.hh>

using namespace Dune;

void foo(const BCRSMatrix<FieldMatrix<double,1,1> >& matrix) { BCRSMatrix<FieldMatrix<double,1,1> >::row_type::iterator it = matrix[0].begin(); (*it)[0][0] = 42; }

int main (int argc, char *argv[]) { BCRSMatrix<FieldMatrix<double,1,1> > bcrsMatrix(1,1, BCRSMatrix<FieldMatrix<double,1,1> >::random);

bcrsMatrix.setrowsize(0,1);
bcrsMatrix.endrowsizes();

bcrsMatrix.addindex(0, 0);
bcrsMatrix.endindices();

bcrsMatrix = 0;

std::cout << bcrsMatrix[0][0] << std::endl;

foo(bcrsMatrix);
std::cout << bcrsMatrix[0][0] << std::endl;

}

Note that the method foo modifies a const matrix. Not only does this test case compile, but also the matrix is indeed modified, as can be seen from the test case output. The reason seems to be in the file basearray.hh:578, where there is a copy constructor for a non-const iterator from a const-iterator.