[PATCH] D81179: [flang] avoid GCC < 8 compiler failure after D80794

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 12:10:11 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d9bb031d13c: [flang] avoid GCC < 8 compiler failure after D80794 (authored by clementval).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81179/new/

https://reviews.llvm.org/D81179

Files:
  flang/include/flang/Evaluate/integer.h
  flang/lib/Decimal/big-radix-floating-point.h


Index: flang/lib/Decimal/big-radix-floating-point.h
===================================================================
--- flang/lib/Decimal/big-radix-floating-point.h
+++ flang/lib/Decimal/big-radix-floating-point.h
@@ -179,7 +179,10 @@
       if (remove >= digits_) {
         digits_ = 0;
       } else if (remove > 0) {
-        for (int j{0}; j + remove < digits_; ++j) {
+        // (&& j + remove < maxDigits) was added to avoid GCC < 8 build failure
+        // on -Werror=array-bounds
+        for (int j{ 0 }; j + remove < digits_ && (j + remove < maxDigits);
+             ++j) {
           digit_[j] = digit_[j + remove];
         }
         digits_ -= remove;
Index: flang/include/flang/Evaluate/integer.h
===================================================================
--- flang/include/flang/Evaluate/integer.h
+++ flang/include/flang/Evaluate/integer.h
@@ -805,7 +805,9 @@
           if (Part ypart{y.LEPart(k)}) {
             BigPart xy{xpart};
             xy *= ypart;
-            for (int to{j + k}; xy != 0; ++to) {
+            // && to < (2 * parts) was added to avoid GCC < 8 build failure
+            // on -Werror=array-bounds
+            for (int to{ j + k }; xy != 0 && to < (2 * parts); ++to) {
               xy += product[to];
               product[to] = xy & partMask;
               xy >>= partBits;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81179.268554.patch
Type: text/x-patch
Size: 1343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200604/cf38ed8d/attachment-0001.bin>


More information about the llvm-commits mailing list