From 08c0d1f27ae3a207bb209d93df7f34562cbfdda9 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Mon, 20 Nov 2023 16:04:13 -0800 Subject: [PATCH] dev: Fix `std::min` type mismatch in reg_bank.hh https://github.com/gem5/gem5/pull/386 included two cases in "src/dev/reg_bank.hh" where `std:: min` was used to compare a an integer of type `size_t` and another of type `Addr`. This cause an error on my Apple Silicon Mac as this is a comparison between an "unsigned long" and an "unsigned long long" which (at least on my setup) was not permitted. To fix this issue the `reg_size` was changed from `size_t` to `Addr`, as well as it the types of the values it was derived from and the variable used to hold the return from the `std::min` calls. Change-Id: I31e9c04a8e0327d4f6f5390bc5a743c629db4746 --- src/dev/reg_bank.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dev/reg_bank.hh b/src/dev/reg_bank.hh index c639a2d562..9f53c44e38 100644 --- a/src/dev/reg_bank.hh +++ b/src/dev/reg_bank.hh @@ -979,9 +979,9 @@ class RegisterBank : public RegisterBankBase std::ostringstream ss; while (done != bytes) { RegisterBase ® = it->second.get(); - const size_t reg_off = addr - it->first; - const size_t reg_size = reg.size() - reg_off; - const size_t reg_bytes = std::min(reg_size, bytes - done); + const Addr reg_off = addr - it->first; + const Addr reg_size = reg.size() - reg_off; + const Addr reg_bytes = std::min(reg_size, bytes - done); if (reg_bytes != reg.size()) { if (_debug_flag) { @@ -1025,9 +1025,9 @@ class RegisterBank : public RegisterBankBase std::ostringstream ss; while (done != bytes) { RegisterBase ® = it->second.get(); - const size_t reg_off = addr - it->first; - const size_t reg_size = reg.size() - reg_off; - const size_t reg_bytes = std::min(reg_size, bytes - done); + const Addr reg_off = addr - it->first; + const Addr reg_size = reg.size() - reg_off; + const Addr reg_bytes = std::min(reg_size, bytes - done); if (reg_bytes != reg.size()) { if (_debug_flag) {