JDK-8300113 : C2: Single-bit fields with signed type in TypePtr after JDK-8297933
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-01-13
  • Updated: 2023-01-13
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
21Unresolved
Related Reports
Relates :  
Description
JDK-8297933 added new fields to `TypePtr`:

```
    int _hash_computed:1;
    int _exact_klass_computed:1;
    int _is_loaded_computed:1;
```

SonarCloud reports a warning for them:
  Single-bit named bit fields should not be of a signed type cpp:S2216

With 1 bit field, there is only a place for sign, not the value. Storing "1" into that field might effectively converts it to "-1" on the compilers I have tried. These fields are currently used as "booleans" by boolean-converting non-zeros to true, so there is no bug yet for those compilers. But, I can see how a compiler can convert "1" to "0", only effectively storing the sign bit, introducing subtle bugs.

Comments
ILW = potential risk of miscompilation; no failure observed yet since introduction of JDK-8297933; no known workaround = MLH = P4
13-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11989 Date: 2023-01-13 10:41:06 +0000
13-01-2023