mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 10:58:11 +08:00
[flang] avoid GCC < 8 compiler failure after D80794
Summary:
Patch D80794 remove the custom flags for release build for flang.
This leads to build failure with GCC < 8. This patch add upperbound check
in order to avoid the -Werror=array-bounds to trigger a build failure.
```
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
digit_[j] = digit_[j + remove];
~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
digit_[j] = digit_[j + remove];
~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
digit_[j] = digit_[j + remove];
~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
digit_[j] = digit_[j + remove];
~~~~~~^
/home/4vn/versioning/llvm-project/flang/lib/Decimal/big-radix-floating-point.h:183:29: error: array subscript is above array bounds [-Werror=array-bounds]
digit_[j] = digit_[j + remove];
```
```
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
xy += product[to];
~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:810:22: error: array subscript is above array bounds [-Werror=array-bounds]
product[to] = xy & partMask;
~~~~~~~^
/home/4vn/versioning/llvm-project/flang/include/flang/Evaluate/integer.h:809:28: error: array subscript is above array bounds [-Werror=array-bounds]
xy += product[to];
~~~~~~~^
```
Reviewers: DavidTruby, sscalpone, jdoerfert
Reviewed By: DavidTruby
Subscribers: llvm-commits
Tags: #llvm, #flang
Differential Revision: https://reviews.llvm.org/D81179
This commit is contained in:
@@ -805,7 +805,9 @@ public:
|
||||
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;
|
||||
|
||||
@@ -179,7 +179,10 @@ private:
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user