Assignment of Eigen::Map fails with cwiseBinaryOp
Submitted by Lars Kielhorn
Assigned to Nobody
Link to original bugzilla bug (#1187)
Version: 3.2
Operating system: Linux
Description
Created attachment 687
Compile with -std=c++11 flag!
Let A be of type Eigen::Map< Eigen::Matrix<double,2,2> >;
Let B be of type Eigen::Matrix<double,2,1>;
The assignment A = A.cwiseProduct( B * B.transpose() ) works, but A = func(A,B) fails with func(A,B) being defined as follows:
auto func( const Eigen::Map<Eigen::Matrix<double,2,2>>& A,
const Eigen::Matrix<double,2,1>& B )
-> decltype( A.cwiseProduct( B * B.transpose() ) )
{
return A.cwiseProduct( B * B.transpose() );
}
The code compiles fine, but the evaluation of A=func(A,B) causes memory read/write errors.
However, I would have suspected the same behaviour as A=A.cwiseProduct(B*B.transpose()) which, again, runs fine and without errors.
Question: Is this a bug or am I using Eigen3 in a wrong way?
Comment: The attached code fails with Eigen versions 3.2.4 - 3.2.8, but succeeds with Eigen 3.3beta1!
Attachment 687, "Compile with -std=c++11 flag!":
main.cpp