In `powerOfTwo.hpp`, there a few log2 related functions returning `int`. However, some of them always return only unsigned number.
For example, `log2i_exact` essentially calls `count_trailing_zeros`, which returns `unsigned`.
Comments
Runtime Triage: This is not on our current list of priorities. We will consider this feature if we receive additional customer requirements.
17-06-2025
I use clang so they show up as soon as I enable -Wconversion. Nothing particular about this one; some G1 code assigns the result of log2 to an unsigned, and I think the correct fix (of getting ride of the warning) is to change the return-type of log2.
27-09-2023
If I turn on -Wsign-conversion there are thousands of additional errors than just turning on -Wconversion. Why is this one called out?
27-09-2023
clang and gcc have diff behavior regarding -Wconversion.
In gcc, one needs `-Wsign-conversion` additionally to get what clang does with `-Wconversion` alone.
"Warnings about conversions between signed and unsigned integers are disabled by default in C++ unless -Wsign-conversion is explicitly enabled." from https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
If you switch to clang or turns on the additional warning, you will see the uint-to-int warning sites inside that file.
26-09-2023
I don't see these errors when running with -Wconversion. I only get this:
src/hotspot/share/gc/g1/g1RemSet.cpp:263:38: warning: conversion from 'int' to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
263 | _log_scan_chunks_per_region(log2i(_scan_chunks_per_region)),
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~