New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1333 - Compiler error for Array wrapper in Eigen 3.3
Compiler error for Array wrapper in Eigen 3.3
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - expression templates
3.3 (current stable)
x86 - 64-bit All
: Normal Compilation Problem
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-10-21 00:42 UTC by Yixuan Qiu
Modified: 2016-10-24 20:24 UTC (History)
3 users (show)



Attachments

Description Yixuan Qiu 2016-10-21 00:42:25 UTC
Hi all,

Not sure if this is really a bug, but I detected a compiler error for Array wrapper in Eigen 3.3 that did not occur in Eigen 3.2.x.

A minimal example to reproduce the issue is given below:


========================================================================

#include <Eigen/Core>

template <typename Derived>
double colsum(const Eigen::MatrixBase<Derived>& x)
{
    return x.array().sum();
}

int main()
{
    Eigen::MatrixXd x = Eigen::MatrixXd::Random(5, 5);
    double r = colsum(x.col(0));
    
    return 0;
}

========================================================================


The code works fine with Eigen 3.2.10 but generates the following error with Eigen 3.3-rc1:

########################################################################

./Eigen/src/Core/ArrayWrapper.h:83:48: error: binding ‘const Scalar {aka const double}’ to reference of type ‘Eigen::ArrayWrapper<const Eigen::Block<Eigen::Matrix<double, -1, -1>, -1, 1, true> >::Scalar& {aka double&}’ discards qualifiers
       return m_expression.coeffRef(rowId, colId);
                                                ^
########################################################################


GCC version is 6.2.1.
Comment 1 Gael Guennebaud 2016-10-24 20:24:57 UTC
Fixed: https://bitbucket.org/eigen/eigen/commits/3c986dbcba0c/

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