diff --git a/flang/runtime/unit-map.h b/flang/runtime/unit-map.h --- a/flang/runtime/unit-map.h +++ b/flang/runtime/unit-map.h @@ -15,6 +15,7 @@ #include "lock.h" #include "memory.h" #include "unit.h" +#include namespace Fortran::runtime::io { @@ -59,7 +60,7 @@ }; static constexpr int buckets_{1031}; // must be prime - int Hash(int n) { return n % buckets_; } + int Hash(int n) { return std::abs(n) % buckets_; } ExternalFileUnit *Find(int n) { Chain *previous{nullptr};