lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master fc38ed41 1/3: Avoid a gcc '-Wstrict-overflow'


From: Greg Chicares
Subject: [lmi-commits] [lmi] master fc38ed41 1/3: Avoid a gcc '-Wstrict-overflow' diagnostic
Date: Mon, 13 Jun 2022 13:20:11 -0400 (EDT)

branch: master
commit fc38ed41c985f0c797230ab5c21ce466d96205e9
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Avoid a gcc '-Wstrict-overflow' diagnostic
---
 vector_test.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/vector_test.cpp b/vector_test.cpp
index 6a2bcc8c..a13b83cc 100644
--- a/vector_test.cpp
+++ b/vector_test.cpp
@@ -183,8 +183,14 @@ class simple_array0
     typedef binary_expression<double const*,double const*,plus> add_t;
     simple_array0& operator=(add_t e)
         {
-        for(double* i = begin(); i < end(); ++i, ++e)
-            {*i = *e;}
+    // With '-Wstrict-overflow', gcc complains about '<' here:
+    //   assuming pointer wraparound does not occur when comparing
+    //     P +- C1 with P +- C2
+//      for(double* i = begin(); i < end(); ++i, ++e)
+//          {*i = *e;}
+    // so write the loop this way instead:
+        for(int i = 0; i < length_; ++i, ++e)
+            {*(begin() + i) = *e;}
         return *this;
         }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]