This bugzilla service is closed. All entries have been migrated to
Bug 1009 - One-index coeff accessors should static_assert on LinearAccessBit
Summary: One-index coeff accessors should static_assert on LinearAccessBit
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - expression templates (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
Depends on:
Blocks: 3.3
  Show dependency treegraph
Reported: 2015-05-01 15:10 UTC by Benoit Jacob
Modified: 2019-12-04 14:35 UTC (History)
3 users (show)

minimal testcase (135 bytes, text/x-c++src)
2015-05-01 15:10 UTC, Benoit Jacob
no flags Details
Add static assertions on linear access. Breaks lots of tests at the moment. (2.69 KB, patch)
2015-05-01 15:11 UTC, Benoit Jacob
no flags Details | Diff

Description Benoit Jacob 2015-05-01 15:10:30 UTC
Created attachment 570 [details]
minimal testcase

coeff(Index) and coeffRef(Index), and corresponding operator()(Index) and operator[], should probably require LinearAccessBit, right?

The attached testcase is how I came across this: I was mistakenly using operator()(Index) on a Block<MatrixXf>, so I was addressing coefficients outside of the block.

Also attaching a patch that does this static-assertion; but I can't push it at the moment, because it seems to be breaking lots of tests, and I don't currently have time to look into them...
Comment 1 Benoit Jacob 2015-05-01 15:11:51 UTC
Created attachment 571 [details]
Add static assertions on linear access. Breaks lots of tests at the moment.
Comment 2 Gael Guennebaud 2015-11-12 16:30:30 UTC
This flags is now handled by the evaluator, so the test should be internal::evaluator<Derived>::Flags&LinearAccessBit, but that does not seem to be sufficient. If I relax it to:

bool(internal::evaluator<Derived>::Flags & LinearAccessBit) || Derived::IsVectorAtCompileTime

then everything compile again meaning that some vector expressions does not have the LinearAccessBit flag...
Comment 3 Gael Guennebaud 2015-11-27 09:08:13 UTC
Summary:     Bug 1009, part 1/2: make sure vector expressions expose LinearAccessBit flag.
Summary:     Bug 1009, part 2/2: add static assertion on LinearAccessBit in coeff(index)-like methods.
Comment 4 Nobody 2019-12-04 14:35:59 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.