New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 882 - const-correctness loophole in {CwiseUnary|Triangular|SelfAdjoint}View
Summary: const-correctness loophole in {CwiseUnary|Triangular|SelfAdjoint}View
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.2
Hardware: All All
: High Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.3
  Show dependency treegraph
 
Reported: 2014-09-22 22:12 UTC by Christoph Hertzberg
Modified: 2014-10-07 18:30 UTC (History)
3 users (show)



Attachments

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.

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