From a7ae628c9f8a83973e899866ecd344bbfde6e844 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 8 Jun 2015 10:14:08 +0200 Subject: [PATCH] bug #1005: fix regression regarding sparse coeff-wise binary operator that did not trigger a static assertion for mismatched storage --- Eigen/src/SparseCore/SparseCwiseBinaryOp.h | 18 ++++++++++++++++++ failtest/CMakeLists.txt | 2 ++ failtest/sparse_storage_mismatch.cpp | 16 ++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 failtest/sparse_storage_mismatch.cpp diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index f53427abf..096af7fb0 100644 --- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h @@ -29,6 +29,24 @@ namespace Eigen { // 4 - dense op dense product dense // generic dense +template +class CwiseBinaryOpImpl + : public SparseMatrixBase > +{ + public: + typedef CwiseBinaryOp Derived; + EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) + CwiseBinaryOpImpl() + { + typedef typename internal::traits::StorageKind LhsStorageKind; + typedef typename internal::traits::StorageKind RhsStorageKind; + EIGEN_STATIC_ASSERT(( + (!internal::is_same::value) + || ((Lhs::Flags&RowMajorBit) == (Rhs::Flags&RowMajorBit))), + THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH); + } +}; + namespace internal { template Mat1; +#ifdef EIGEN_SHOULD_FAIL_TO_BUILD +typedef SparseMatrix Mat2; +#else +typedef SparseMatrix Mat2; +#endif + +int main() +{ + Mat1 a(10,10); + Mat2 b(10,10); + a += b; +}