RFR: 8313302: Fix formatting errors on Windows [v3]
David Holmes
dholmes at openjdk.org
Mon Aug 7 03:59:29 UTC 2023
On Mon, 7 Aug 2023 02:27:07 GMT, Julian Waters <jwaters at openjdk.org> wrote:
>> src/hotspot/share/code/codeHeapState.cpp line 1387:
>>
>>> 1385: " occupied space) is used by the blocks in the given size range.\n"
>>> 1386: " %ld characters are printed per percentage point.\n", pctFactor/100);
>>> 1387: ast->print_cr("total size of all blocks: " INT64_FORMAT_W(7) "M", (total_size<<log2_seg_size)/M);
>>
>> Wrong for 32-bit platforms.
>
> I don't quite know what to do here, since on platforms where long < size_t (which in practice is probably just 32 bit or Windows) this division will promote to the type of size_t, which is likely 64 bits in size, but unfortunately %zd cannot be used here since the promotion only happens on said platforms where long < size_t, which will trip a compilation breaking warning on platforms where sizeof long is sizeof size_t, which is probably just 64 bit platforms that are not Windows
If we defer the issue of what type `total_size` should be and just keep it as `unsigned long` then the simple and correct fix would be to use `%7lu` would it not?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15063#discussion_r1285354581
More information about the hotspot-dev
mailing list