From e2485000c7d7158097be01e29a6e18d7fe899d00 Mon Sep 17 00:00:00 2001 From: George Rennie Date: Thu, 8 May 2025 11:08:20 +0200 Subject: [PATCH] kernel: handle unsigned case for as_int_saturating correctly * This fixes #5105 --- kernel/rtlil.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 9f5972c32..c08e78dce 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -396,6 +396,9 @@ std::optional RTLIL::Const::try_as_int(bool is_signed) const int RTLIL::Const::as_int_saturating(bool is_signed) const { if (!convertible_to_int(is_signed)) { + if (!is_signed) + return std::numeric_limits::max(); + const auto min_size = get_min_size(is_signed); log_assert(min_size > 0); const auto neg = get_bits().at(min_size - 1);