diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h index f18829866..14b196480 100644 --- a/Eigen/src/SparseCore/SparseMatrix.h +++ b/Eigen/src/SparseCore/SparseMatrix.h @@ -665,8 +665,15 @@ class SparseMatrix YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) check_template_parameters(); const bool needToTranspose = (Flags & RowMajorBit) != (internal::evaluator::Flags & RowMajorBit); - if (needToTranspose) *this = other.derived(); - else internal::call_assignment_no_alias(*this, other.derived()); + if (needToTranspose) + *this = other.derived(); + else + { + #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN + EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN + #endif + internal::call_assignment_no_alias(*this, other.derived()); + } } /** Constructs a sparse matrix from the sparse selfadjoint view \a other */ diff --git a/test/sparse_ref.cpp b/test/sparse_ref.cpp index d173ee658..93fb5efe7 100644 --- a/test/sparse_ref.cpp +++ b/test/sparse_ref.cpp @@ -64,6 +64,7 @@ void call_ref() const SparseMatrix& Ac(A); Block > Ab(A,0,1, 3,3); const Block > Abc(A,0,1,3,3); + SparseMatrix AA = A*A; VERIFY_EVALUATION_COUNT( call_ref_1(A, A), 0); @@ -80,8 +81,8 @@ void call_ref() VERIFY_EVALUATION_COUNT( call_ref_3(B, B), 1); VERIFY_EVALUATION_COUNT( call_ref_2(B.transpose(), B.transpose()), 0); VERIFY_EVALUATION_COUNT( call_ref_3(B.transpose(), B.transpose()), 0); - VERIFY_EVALUATION_COUNT( call_ref_2(A*A, A*A), 1); - VERIFY_EVALUATION_COUNT( call_ref_3(A*A, A*A), 1); + VERIFY_EVALUATION_COUNT( call_ref_2(A*A, AA), 1); + VERIFY_EVALUATION_COUNT( call_ref_3(A*A, AA), 1); VERIFY(!C.isCompressed()); VERIFY_EVALUATION_COUNT( call_ref_3(C, C), 1);