New user self-registration is currently disabled. Please email eigen-core-team @ if you need an account.
Bug 1410 - Constness in block expressions changed behavior
Constness in block expressions changed behavior
Product: Eigen
Classification: Unclassified
Component: Core - general
3.3 (current stable)
All All
: Normal Compilation Problem
Assigned To: Nobody
Depends on:
  Show dependency treegraph
Reported: 2017-03-27 11:08 UTC by Simon Praetorius
Modified: 2017-06-09 11:15 UTC (History)
3 users (show)


Description Simon Praetorius 2017-03-27 11:08:21 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 = ...`?
Comment 1 Simon Praetorius 2017-03-27 11:15:20 UTC
I think this is related to a change in `src/Core/Block.h` by commit e9e716edd188:

where the `internal::const_cast_ptr` was replaced by something else.
Comment 2 Christoph Hertzberg 2017-03-27 11:35:59 UTC
It looks like the problem is that 
  traits<ArrayWrapper<ExpressionType> >::Flags
has the LvalueBit set, even for const MatrixXd.

Note You need to log in before you can comment on or make changes to this bug.