This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 882

Summary: const-correctness loophole in {CwiseUnary|Triangular|SelfAdjoint}View
Product: Eigen Reporter: Christoph Hertzberg <chtz>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: Compilation Problem CC: chtz, gael.guennebaud, jacob.benoit.1
Priority: High    
Version: 3.2   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 558    

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:

https://bitbucket.org/eigen/eigen/commits/7e652ad5b688/
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
https://bitbucket.org/eigen/eigen/commits/15747271eb5a/
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 gitlab.com'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: https://gitlab.com/libeigen/eigen/issues/882.