From 7a3009f7a397dca9a86b7e4f2ee441f9bba3eb7d Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 14 Jul 2020 08:47:42 +0200 Subject: [PATCH] Remove asserts for unsigned integer >= 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 10 gives a warning "comparison of unsigned expression in ‘>= 0’ is always true" for these asserts since checking if an unsigned integer cannot be negative and hence the statement gets droped. --- matrix/Matrix.hpp | 8 -------- matrix/Slice.hpp | 6 ------ matrix/SquareMatrix.hpp | 7 ------- matrix/Vector.hpp | 2 -- 4 files changed, 23 deletions(-) diff --git a/matrix/Matrix.hpp b/matrix/Matrix.hpp index 97e1ebf76f..e54c99a257 100644 --- a/matrix/Matrix.hpp +++ b/matrix/Matrix.hpp @@ -96,9 +96,7 @@ public: inline const Type &operator()(size_t i, size_t j) const { - assert(i >= 0); assert(i < M); - assert(j >= 0); assert(j < N); return _data[i][j]; @@ -106,9 +104,7 @@ public: inline Type &operator()(size_t i, size_t j) { - assert(i >= 0); assert(i < M); - assert(j >= 0); assert(j < N); return _data[i][j]; @@ -494,9 +490,7 @@ public: inline void swapRows(size_t a, size_t b) { - assert(a >= 0); assert(a < M); - assert(b >= 0); assert(b < M); if (a == b) { @@ -514,9 +508,7 @@ public: inline void swapCols(size_t a, size_t b) { - assert(a >= 0); assert(a < N); - assert(b >= 0); assert(b < N); if (a == b) { diff --git a/matrix/Slice.hpp b/matrix/Slice.hpp index faf211ca73..4040099839 100644 --- a/matrix/Slice.hpp +++ b/matrix/Slice.hpp @@ -28,17 +28,13 @@ public: _data(const_cast*>(data)) { static_assert(P <= M, "Slice rows bigger than backing matrix"); static_assert(Q <= N, "Slice cols bigger than backing matrix"); - assert(x0 >= 0); assert(x0 + P <= M); - assert(y0 >= 0); assert(y0 + Q <= N); } const Type &operator()(size_t i, size_t j) const { - assert(i >= 0); assert(i < P); - assert(j >= 0); assert(j < Q); return (*_data)(_x0 + i, _y0 + j); @@ -47,9 +43,7 @@ public: Type &operator()(size_t i, size_t j) { - assert(i >= 0); assert(i < P); - assert(j >= 0); assert(j < Q); return (*_data)(_x0 + i, _y0 + j); diff --git a/matrix/SquareMatrix.hpp b/matrix/SquareMatrix.hpp index 216ff172d8..8c35351664 100644 --- a/matrix/SquareMatrix.hpp +++ b/matrix/SquareMatrix.hpp @@ -136,7 +136,6 @@ public: void uncorrelateCovariance(size_t first) { static_assert(Width <= M, "Width bigger than matrix"); - assert(first >= 0); assert(first + Width <= M); SquareMatrix &self = *this; @@ -148,7 +147,6 @@ public: void uncorrelateCovarianceSetVariance(size_t first, const Vector &vec) { static_assert(Width <= M, "Width bigger than matrix"); - assert(first >= 0); assert(first + Width <= M); SquareMatrix &self = *this; @@ -168,7 +166,6 @@ public: void uncorrelateCovarianceSetVariance(size_t first, Type val) { static_assert(Width <= M, "Width bigger than matrix"); - assert(first >= 0); assert(first + Width <= M); SquareMatrix &self = *this; @@ -187,7 +184,6 @@ public: void makeBlockSymmetric(size_t first) { static_assert(Width <= M, "Width bigger than matrix"); - assert(first >= 0); assert(first + Width <= M); SquareMatrix &self = *this; @@ -207,7 +203,6 @@ public: void makeRowColSymmetric(size_t first) { static_assert(Width <= M, "Width bigger than matrix"); - assert(first >= 0); assert(first + Width <= M); SquareMatrix &self = *this; @@ -231,7 +226,6 @@ public: bool isBlockSymmetric(size_t first, const Type eps = 1e-8f) { static_assert(Width <= M, "Width bigger than matrix"); - assert(first >= 0); assert(first + Width <= M); SquareMatrix &self = *this; @@ -252,7 +246,6 @@ public: bool isRowColSymmetric(size_t first, const Type eps = 1e-8f) { static_assert(Width <= M, "Width bigger than matrix"); - assert(first >= 0); assert(first + Width <= M); SquareMatrix &self = *this; diff --git a/matrix/Vector.hpp b/matrix/Vector.hpp index e9c0d1f1ab..e5bdd43dc5 100644 --- a/matrix/Vector.hpp +++ b/matrix/Vector.hpp @@ -42,7 +42,6 @@ public: inline const Type &operator()(size_t i) const { - assert(i >= 0); assert(i < M); const MatrixM1 &v = *this; @@ -51,7 +50,6 @@ public: inline Type &operator()(size_t i) { - assert(i >= 0); assert(i < M); MatrixM1 &v = *this;