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



Attachments

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:

Example:
```
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: 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.
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.