[flang-commits] [PATCH] D83428: [flang] Fix negative unit number hashing
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Jul 8 14:48:15 PDT 2020
klausler created this revision.
klausler added reviewers: tskeith, sscalpone.
klausler added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Ensure that external unit number hashing produces a valid
index for a negative unit number, viz. a NEWUNIT=.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83428
Files:
flang/runtime/unit-map.h
Index: flang/runtime/unit-map.h
===================================================================
--- flang/runtime/unit-map.h
+++ flang/runtime/unit-map.h
@@ -15,6 +15,7 @@
#include "lock.h"
#include "memory.h"
#include "unit.h"
+#include <cstdlib>
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};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83428.276561.patch
Type: text/x-patch
Size: 542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200708/856a2aa2/attachment.bin>
More information about the flang-commits
mailing list