Summary: | Column access of some IndexedView won't compile | ||
---|---|---|---|
Product: | Eigen | Reporter: | Antoine Bussy <bussyantoine> |
Component: | Core - expression templates | Assignee: | Nobody <eigen.nobody> |
Status: | RESOLVED FIXED | ||
Severity: | Compilation Problem | CC: | bussyantoine, chtz, gael.guennebaud, jacob.benoit.1 |
Priority: | Normal | Keywords: | test-needed |
Version: | 3.4 (development) | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Bug Depends on: | |||
Bug Blocks: | 814 |
Description
Antoine Bussy
2019-08-07 11:34:28 UTC
The actual problem here is that `.coeff(Index)` is called -- even though only in a false-branch, i.e., never executed. With C++17 this would be trivial to workaround using if constexpr (ForwardLinearAccess) {...} Your patch should work of course (since it will never actually be called). But perhaps we should add assertions that the expression is a vector at compile time (actually, also to the corresponding Block::coeff methods) Ideally, m(X, Y).col(i) could be simplified to m(X,Y[i]) -- similar for any other block-operations. Thanks for the answer, adding constexpr in CoreEvaluator.h is indeed much cleaner :) Concerning m(X,Y[i]), I can't really use this simplification in my code since m(X,Y) is the input of a function that works on matrices. For a non-C++17 workaround, it is possible to emulate the if constexpr with a small amount of boilerplate: EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff_impl(std::true_type, Index index) const { return m_argImpl.coeff(m_linear_offset.value() + index); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff_impl(std::false_type, Index index) const { return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return coeff_impl(std::bool_constant<ForwardLinearAccess>{}, index); } Of course, it would be necessary to reimplement std::bool_constant, but this is trivial. Thank you for reporting this issue and suggesting a fix. https://bitbucket.org/eigen/eigen/commits/f4920c83f9c4/ -- 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/1736. |