Bugzilla – Bug 1410
Constness in block expressions changed behavior
Last modified: 2017-06-09 11:15:11 UTC
When converting a matrix into an array and extracting a block-view afterwards, the behavior is changed due to const-properties from 3.2.x to 3.3.x:
using Matrix = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>;
Matrix const m(10,10);
auto a = m.array();
auto r = a.row(1); // error: invalid conversion from `const double*` to `double*`
The code works find in 3.2.x but not in 3.3.x. If I change `auto a = ...` to `auto const a = ...` all is fine in 3.3.
I have not found a note in the changelogs or this bug-tracker that addresses this issue, but maybe I just missed it.
What is the correct behavior? The old one, or the new one, i.e. should it be `auto const a = ...`?
I think this is related to a change in `src/Core/Block.h` by commit e9e716edd188: https://bitbucket.org/eigen/eigen/src/e9e716edd188/Eigen/src/Core/Block.h?at=default
where the `internal::const_cast_ptr` was replaced by something else.
It looks like the problem is that
has the LvalueBit set, even for const MatrixXd.