RFR: 8311847: Fix -Wconversion for assembler.hpp emit_int8,16 callers

Coleen Phillimore coleenp at openjdk.org
Tue Jul 11 12:19:12 UTC 2023


On Tue, 11 Jul 2023 08:38:56 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Please review changes to fix -Wconversion warnings that come from assembler_<cpu>.cpp by adding narrow_casts to the emit_int8,16,24, and 32 functions.  And some other fixups with checked_cast.
>> 
>> Ran tier1 on Oracle platforms, and tier1-4 on linux-x64-debug, linux-aarch64-debug, windows-x64-debug.
>
> src/hotspot/share/asm/assembler.hpp line 297:
> 
>> 295:   constexpr T narrow_cast(int x) const {
>> 296:    if (x < 0) {
>> 297:     assert(x > -(std::numeric_limits<T>::max() - 1), "too negative");
> 
> Suggestion:
> 
>     assert(x >= -std::numeric_limits<T>::max() - 1, "too negative"); // >= -256 for 8 bits
> 
> The old code would have checked > -254 I think, when it should be > -257 or >= -256

Thank you - I meant to check these values.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14822#discussion_r1259649487


More information about the hotspot-compiler-dev mailing list