mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-16 14:49:39 +08:00
bug #1410: fix lvalue propagation of Array/Matrix-Wrapper with a const nested expression.
This commit is contained in:
parent
723a59ac26
commit
fb1ee04087
@ -32,7 +32,8 @@ struct traits<ArrayWrapper<ExpressionType> >
|
||||
// Let's remove NestByRefBit
|
||||
enum {
|
||||
Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
|
||||
Flags = Flags0 & ~NestByRefBit
|
||||
LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,
|
||||
Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -129,7 +130,8 @@ struct traits<MatrixWrapper<ExpressionType> >
|
||||
// Let's remove NestByRefBit
|
||||
enum {
|
||||
Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
|
||||
Flags = Flags0 & ~NestByRefBit
|
||||
LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,
|
||||
Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -235,12 +235,31 @@ template<typename MatrixTraits> void resize(const MatrixTraits& t)
|
||||
VERIFY(a1.size()==cols);
|
||||
}
|
||||
|
||||
template<int>
|
||||
void regression_bug_654()
|
||||
{
|
||||
ArrayXf a = RowVectorXf(3);
|
||||
VectorXf v = Array<float,1,Dynamic>(3);
|
||||
}
|
||||
|
||||
// Check propagation of LvalueBit through Array/Matrix-Wrapper
|
||||
template<int>
|
||||
void regrrssion_bug_1410()
|
||||
{
|
||||
const Matrix4i M;
|
||||
const Array4i A;
|
||||
ArrayWrapper<const Matrix4i> MA = M.array();
|
||||
MA.row(0);
|
||||
MatrixWrapper<const Array4i> AM = A.matrix();
|
||||
AM.row(0);
|
||||
|
||||
VERIFY((internal::traits<ArrayWrapper<const Matrix4i> >::Flags&LvalueBit)==0);
|
||||
VERIFY((internal::traits<MatrixWrapper<const Array4i> >::Flags&LvalueBit)==0);
|
||||
|
||||
VERIFY((internal::traits<ArrayWrapper<Matrix4i> >::Flags&LvalueBit)==LvalueBit);
|
||||
VERIFY((internal::traits<MatrixWrapper<Array4i> >::Flags&LvalueBit)==LvalueBit);
|
||||
}
|
||||
|
||||
void test_array_for_matrix()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
@ -280,5 +299,6 @@ void test_array_for_matrix()
|
||||
CALL_SUBTEST_5( resize(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_6( resize(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
}
|
||||
CALL_SUBTEST_6( regression_bug_654() );
|
||||
CALL_SUBTEST_6( regression_bug_654<0>() );
|
||||
CALL_SUBTEST_6( regrrssion_bug_1410<0>() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user