This bugzilla service is closed. All entries have been migrated to
Bug 1410 - Constness in block expressions changed behavior
Summary: Constness in block expressions changed behavior
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Compilation Problem
Assignee: Nobody
Depends on:
Reported: 2017-03-27 11:08 UTC by Simon Praetorius
Modified: 2019-12-04 16:54 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.
Comment 4 Nobody 2019-12-04 16:54:44 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

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