Ensure that external unit number hashing produces a valid
index for a negative unit number, viz. a NEWUNIT=.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D83428
#include "lock.h"
#include "memory.h"
#include "unit.h"
+#include <cstdlib>
namespace Fortran::runtime::io {
};
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};