RFR(XXS): 8135179: Fix conversion warning after 8067341

Volker Simonis volker.simonis at gmail.com
Tue Sep 8 16:56:46 UTC 2015


can somebody please review and sponsor the following trivial fix:


Change "8067341: Modify PLAB sizing algorithm to waste less"
introduced the following code:

size_t const cur_plab_sz = (double)total_waste_allowed /

which triggers a conversion warning with older versions of GCC and
potentially other compilers as well:

hotspot-rt/src/share/vm/gc/g1/g1EvacStats.cpp: In member function
'virtual void G1EvacStats::adjust_desired_plab_sz()':
hotspot-rt/src/share/vm/gc/g1/g1EvacStats.cpp:96: warning: converting
to 'size_t' from 'double'
make[4]: *** [g1EvacStats.o] Error 1

The warning can be easily fixed as follows:

size_t const cur_plab_sz = (sizte_t)((double)total_waste_allowed /

Thank you and best regards,

PS: as a side note I want to mention that we are currently disabling
'-Wconversion' for GCC 4.3 and later because it produces too many
warnings which are by default treated as errors. All the warnings
produced by '-Wconversion' are about narrowing conversions which may
result in a potential data loss.

It may be a good idea to fix all these implicit narrowing conversions
and re-enable -Wconversion warning by default.

But unfortunately there's quite some code which has to be changed in
order to meet the requirements of '-Wconversion'. A quick research
showed that there are currently 137 different implicit narrowing
conversions spread over 1785 different code locations.

For more details see "8135181: Re-enable '-Wconversion' for GCC 4.3
and later" (https://bugs.openjdk.java.net/browse/JDK-8135181) which
I've opened to track the issue.

What's the general opinion? Would it be worth wile to fix all these
conversion warnings by inserting implicit casts?

More information about the hotspot-dev mailing list