On Tue, 27 Aug 2024 12:10:36 GMT, David Holmes <dhol...@openjdk.org> wrote:

>> src/hotspot/share/utilities/utf8.cpp line 127:
>> 
>>> 125:     prev = c;
>>> 126:   }
>>> 127:   return checked_cast<int>(num_chars);
>> 
>> Ideally, this function would return size_t.
>
> Why? I think that would have a large flow on effect. And this length does fit 
> in an int.

The worse case is len == SIZE_MAX and therefore num_chars == SIZE_MAX, which 
won't fit in an int.  If we say this will never happen because current callers 
never use sizes bigger than int, that makes the code fragile against scenarios 
where a developer might add a new caller.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20560#discussion_r1733226733

Reply via email to