From: Wolfgang Bangerth Date: Fri, 7 Jan 2022 07:19:23 +0000 (-0700) Subject: Fix comparison of objects. X-Git-Tag: v9.4.0-rc1~645^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8c6b4c403ae1f31071cd38d09d1dab85e4858d0;p=dealii.git Fix comparison of objects. --- 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; }