JDK-8308396 : Fix offset_of conversion warnings in runtime code
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-05-18
  • Updated: 2023-05-25
  • Resolved: 2023-05-19
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 21
21 b24Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
The definition of offset_of() in globalDefinitions_*.hpp returns a type size_t which in all the uses in header files does an implicit conversion down to an 'int'.   The 'int' is large enough to hold offset_of things and there's a function and comment in src/hotspot/share/utilities/sizes.hpp:

    // Use the following #define to get C++ field member offsets
    #define byte_offset_of(klass,field)   in_ByteSize((int)offset_of(klass, field))

Fixing the header file uses of offset_of avoids -Wconversion warnings when also disabling -Werror from 1,621,150 to 863,682 lines of warnings.

Comments
Changeset: 265f40b4 Author: Coleen Phillimore <coleenp@openjdk.org> Date: 2023-05-19 17:16:04 +0000 URL: https://git.openjdk.org/jdk/commit/265f40b4f70102c37bf28b2bf9dda16b92d1d975
19-05-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14053 Date: 2023-05-18 22:37:57 +0000
18-05-2023