From e101edc0e7616a224dacd1ef52f0ef3a6d00c53e Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 24 Aug 2020 14:19:43 +0200 Subject: [PATCH] Matrix: fix warning if M == N (#146) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the warning appearing with GCC 10.2: ../../src/lib/matrix/matrix/Matrix.hpp:481:34: error: logical ‘and’ of equal expressions [-Werror=logical-op] 481 | for (size_t i = 0; i < M && i < N; i++) { | I would prefered something with if constexpr but we don't have that yet in because we're using C++14. --- matrix/Matrix.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matrix/Matrix.hpp b/matrix/Matrix.hpp index e54c99a257..d7e57e37ef 100644 --- a/matrix/Matrix.hpp +++ b/matrix/Matrix.hpp @@ -478,7 +478,8 @@ public: setZero(); Matrix &self = *this; - for (size_t i = 0; i < M && i < N; i++) { + const size_t min_i = M > N ? N : M; + for (size_t i = 0; i < min_i; i++) { self(i, i) = 1; } }