RFR: 8313882: Fix -Wconversion warnings in runtime code [v2]
Dean Long
dlong at openjdk.org
Wed Aug 9 01:52:43 UTC 2023
On Wed, 9 Aug 2023 00:24:30 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> src/hotspot/share/runtime/sharedRuntime.cpp line 2348:
>>
>>> 2346: double sum = 0;
>>> 2347: double weighted_sum = 0;
>>> 2348: for (int i = 0; i <= n; i++) { sum += (double)histo[i]; weighted_sum += (double)(i*histo[i]); }
>>
>> So hist is a uint64_t*, why can't we make sum and weighted_sum just uint64_t?
>
> I think there were less casts this way, since sum and weighted sum had to be turned into double more than histo[i], but it does make more sense to use int for summing the numbers, and cast to double for printing.
I don't know how big these values are, but if they were large then uint64_t sum could overflow.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15177#discussion_r1287844731
More information about the graal-dev
mailing list