mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix ASAN-detected bugs in Diagonal::data() and array_cwise test
libeigen/eigen!2182 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
@@ -91,8 +91,12 @@ class Diagonal : public internal::dense_xpr_base<Diagonal<MatrixType, DiagIndex_
|
||||
|
||||
typedef std::conditional_t<internal::is_lvalue<MatrixType>::value, Scalar, const Scalar> ScalarWithConstIfNotLvalue;
|
||||
|
||||
EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }
|
||||
EIGEN_DEVICE_FUNC inline const Scalar* data() const { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }
|
||||
EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() {
|
||||
return rows() > 0 ? &(m_matrix.coeffRef(rowOffset(), colOffset())) : nullptr;
|
||||
}
|
||||
EIGEN_DEVICE_FUNC inline const Scalar* data() const {
|
||||
return rows() > 0 ? &(m_matrix.coeffRef(rowOffset(), colOffset())) : nullptr;
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index) {
|
||||
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||
|
||||
@@ -773,6 +773,7 @@ void comparisons(const ArrayType& m) {
|
||||
|
||||
// test bug2966: select did not support some scalar types that forbade implicit conversions from bool
|
||||
ArrayX<scalar_wrapper> m5(10);
|
||||
m5.setConstant(scalar_wrapper(0));
|
||||
m5 = (m5 == scalar_wrapper(0)).select(m5, m5);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user