JDK-8056175 : Change "8048150: Allow easy configurations for large CDS archives" triggers conversion warning with older GCC
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2014-08-27
  • Updated: 2015-06-03
  • Resolved: 2014-08-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b31Fixed
Related Reports
Relates :  
Description
For GCC versions before 4.3 we still use the "-Wconversion" flag so if we build with such a GCC the code introduced by "8048150: Allow easy configurations for large CDS archives" will trigger the following warnings which are treated as errors:

/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp: In static member function 'static void MetaspaceShared::estimate_regions_size()':
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1124: warning: converting to 'uintx' from 'double'
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1125: warning: converting to 'uintx' from 'double'
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1126: warning: converting to 'uintx' from 'double'
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1127: warning: converting to 'uintx' from 'double'
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1129: warning: converting to 'uintx' from 'double'
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1130: warning: converting to 'uintx' from 'double'
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1131: warning: converting to 'uintx' from 'double'
/src/hotspot-rt/src/share/vm/memory/metaspaceShared.cpp:1132: warning: converting to 'uintx' from 'double'

The fix is trivial - just implicitly cast the result of the conversion to uintx:

diff -r 8ae56f4f758f src/share/vm/memory/metaspaceShared.hpp
--- a/src/share/vm/memory/metaspaceShared.hpp   Tue Aug 26 13:07:57 2014 -0700
+++ b/src/share/vm/memory/metaspaceShared.hpp   Wed Aug 27 16:43:39 2014 +0200
@@ -41,7 +41,7 @@
 
 #define SET_ESTIMATED_SIZE(type, region)                              \
   Shared ##region## Size  = FLAG_IS_DEFAULT(Shared ##region## Size) ? \
-    (type ## SharedArchiveSize *  region ## RegionPercentage) : Shared ## region ## Size
+    (uintx)(type ## SharedArchiveSize *  region ## RegionPercentage) : Shared ## region ## Size
 
 class FileMapInfo;