From cd61a1d506c30bbb7c1d69da8fae752183a5b1b5 Mon Sep 17 00:00:00 2001 From: Marcel Koch Date: Thu, 21 Apr 2022 09:49:56 +0200 Subject: [PATCH] add communicator size check to copy/move assignment --- core/distributed/matrix.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/distributed/matrix.cpp b/core/distributed/matrix.cpp index 98d86bd87a6..55971ff4b6f 100644 --- a/core/distributed/matrix.cpp +++ b/core/distributed/matrix.cpp @@ -357,6 +357,8 @@ Matrix::operator=( const Matrix& other) { if (this != &other) { + GKO_ASSERT_EQ(other.get_communicator().size(), + this->get_communicator().size()); this->set_size(other.get_size()); diag_mtx_->copy_from(other.diag_mtx_.get()); offdiag_mtx_->copy_from(other.offdiag_mtx_.get()); @@ -380,6 +382,8 @@ Matrix::operator=( Matrix&& other) noexcept { if (this != &other) { + GKO_ASSERT_EQ(other.get_communicator().size(), + this->get_communicator().size()); this->set_size(other.get_size()); other.set_size({}); diag_mtx_->move_from(other.diag_mtx_.get());