From b8c6b4c403ae1f31071cd38d09d1dab85e4858d0 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 7 Jan 2022 00:19:23 -0700 Subject: [PATCH] Fix comparison of objects. --- include/deal.II/lac/sparsity_pattern.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/deal.II/lac/sparsity_pattern.h b/include/deal.II/lac/sparsity_pattern.h index fa3d9b65df..011acc1acb 100644 --- a/include/deal.II/lac/sparsity_pattern.h +++ b/include/deal.II/lac/sparsity_pattern.h @@ -1644,13 +1644,15 @@ SparsityPatternBase::operator==(const SparsityPatternBase &sp2) const if (rows != sp2.rows || cols != sp2.cols || compressed != sp2.compressed) return false; - for (size_type i = 0; i < rows + 1; ++i) - if (rowstart[i] != sp2.rowstart[i]) - return false; - - for (size_type i = 0; i < rowstart[rows]; ++i) - if (colnums[i] != sp2.colnums[i]) - return false; + if (rows > 0) + for (size_type i = 0; i < rows + 1; ++i) + if (rowstart[i] != sp2.rowstart[i]) + return false; + + if (rows > 0) + for (size_type i = 0; i < rowstart[rows]; ++i) + if (colnums[i] != sp2.colnums[i]) + return false; return true; } -- 2.39.5