base: Fix build errors with gcc 10.x
authorSandipan Das <sandipan@linux.ibm.com>
Fri, 12 Jun 2020 13:41:27 +0000 (19:11 +0530)
committerSandipan Das <sandipan@linux.ibm.com>
Mon, 22 Jun 2020 12:20:09 +0000 (12:20 +0000)
This fixes conditions that perform a redundant check to
see if an unsigned value is greater than or equal to
zero. With gcc 10.x, this generates the following error
because of implicit usage of the "-Werror=type-limits"
flag.

"comparison of unsigned expression in '>= 0' is always true"

Change-Id: Ib1a88035ef5fba410d18de0adf614db4bc634faf
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/30474
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/base/statistics.hh

index 8f665fe0e8e0de42d4c9c4e552c5f40b0af8a3ae..ee541fbc8818f2c6f58e9ced60caf010e8b401f7 100644 (file)
@@ -1161,7 +1161,7 @@ class VectorBase : public DataWrapVec<Derived, VectorInfoProxy>
     Proxy
     operator[](off_type index)
     {
-        assert (index >= 0 && index < size());
+        assert (index < size());
         return Proxy(this->self(), index);
     }
 };
@@ -1235,7 +1235,7 @@ class VectorProxy
     ScalarProxy<Stat>
     operator[](off_type index)
     {
-        assert (index >= 0 && index < size());
+        assert (index < size());
         return ScalarProxy<Stat>(stat, offset + index);
     }
 
@@ -1311,7 +1311,7 @@ class Vector2dBase : public DataWrapVec2d<Derived, Vector2dInfoProxy>
     operator[](off_type index)
     {
         off_type offset = index * y;
-        assert (index >= 0 && offset + y <= size());
+        assert (offset + y <= size());
         return Proxy(this->self(), offset, y);
     }
 
@@ -1995,7 +1995,7 @@ class VectorDistBase : public DataWrapVec<Derived, VectorDistInfoProxy>
 
     Proxy operator[](off_type index)
     {
-        assert(index >= 0 && index < size());
+        assert(index < size());
         return Proxy(this->self(), index);
     }