[flang-commits] [flang] 7643633 - [flang] Runtime validation of SPREAD(DIM=dim) argument
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Mar 7 13:49:46 PST 2022
Author: Peter Klausler
Date: 2022-03-07T13:49:39-08:00
New Revision: 764363368c53b2032f58af42ebd45393305957a9
URL: https://github.com/llvm/llvm-project/commit/764363368c53b2032f58af42ebd45393305957a9
DIFF: https://github.com/llvm/llvm-project/commit/764363368c53b2032f58af42ebd45393305957a9.diff
LOG: [flang] Runtime validation of SPREAD(DIM=dim) argument
Crash when DIM= is not a valid dimension in the result.
Differential Revision: https://reviews.llvm.org/D121145
Added:
Modified:
flang/runtime/transformational.cpp
Removed:
################################################################################
diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index 46cf2ec9b7324..fef4eacc508fb 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -456,6 +456,11 @@ void RTNAME(Spread)(Descriptor &result, const Descriptor &source, int dim,
Terminator terminator{sourceFile, line};
int rank{source.rank() + 1};
RUNTIME_CHECK(terminator, rank <= maxRank);
+ if (dim < 1 || dim > rank) {
+ terminator.Crash("SPREAD: DIM=%d argument for rank-%d source array "
+ "must be greater than 1 and less than or equal to %d",
+ dim, rank - 1, rank);
+ }
ncopies = std::max<std::int64_t>(ncopies, 0);
SubscriptValue extent[maxRank];
int k{0};
More information about the flang-commits
mailing list