This bugzilla service is closed. All entries have been migrated to
Bug 882 - const-correctness loophole in {CwiseUnary|Triangular|SelfAdjoint}View
Summary: const-correctness loophole in {CwiseUnary|Triangular|SelfAdjoint}View
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.2
Hardware: All All
: High Compilation Problem
Assignee: Nobody
Depends on:
Blocks: 3.3
  Show dependency treegraph
Reported: 2014-09-22 22:12 UTC by Christoph Hertzberg
Modified: 2019-12-04 13:45 UTC (History)
3 users (show)


Description Christoph Hertzberg 2014-09-22 22:12:54 UTC
The following assignment should not work:

void triangConstTest(const Eigen::MatrixXd& A) {
  Eigen::TriangularView<Eigen::MatrixXd, Eigen::Upper> T(A);
  T(0,0) = 0.0;  // violates const correctness!
Comment 1 Gael Guennebaud 2014-09-22 23:03:07 UTC
Actually, it should even fail at the first line because the first template argument should be const qualified:

TriangularView<const MatrixXd, Upper> T(A);
Comment 2 Gael Guennebaud 2014-09-22 23:10:26 UTC
Same problem with CwiseUnaryView:

void viewConstTest(const Eigen::MatrixXd& A) {
  Eigen::CwiseUnaryView<internal::scalar_real_ref_op<double>, Eigen::MatrixXd> T(A);
  T.coeffRef(0,0) = 0.0;  // violates const correctness!

and probably with SeflAdjointView too. Only Transpose and Block seems to behave properly.
Comment 3 Gael Guennebaud 2014-09-23 22:35:02 UTC
The regression unit tests:
Changeset:   7e652ad5b688
User:        ggael
Date:        2014-09-23 08:26:02+00:00
Summary:     Bug 882: add const-correctness failtests for CwiseUnaryView, TriangularView, and SelfAdjointView.

Still need to fix them...
Comment 4 Gael Guennebaud 2014-10-07 18:30:13 UTC
Changeset:   15747271eb5a
User:        ggael
Date:        2014-10-07 16:29:28+00:00
Summary:     Bug 882: fix various const-correctness issues with *View classes.
Comment 5 Nobody 2019-12-04 13:45:46 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.