JDK-8345580 : Remove const from Node::_idx which is modified
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 24
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-12-05
  • Updated: 2025-02-17
  • Resolved: 2025-01-08
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 25
25 b05Fixed
Related Reports
Causes :  
Relates :  
Relates :  
Description
Node::_idx is declared as const but it is actually modified by the setter Node::set_idx.

First, this is counterintuitive when reading the code as the reader will assume the variable can never change from only seeing the declaration.

Second, this causes undefined behavior in Node::set_idx as per the C++ standard (section 7.1.6.1.4 for C++14).
Comments
Changeset: ae3fc464 Branch: master Author: Yagmur Eren <yagmur.eren@oracle.com> Committer: Emanuel Peter <epeter@openjdk.org> Date: 2025-01-08 15:14:14 +0000 URL: https://git.openjdk.org/jdk/commit/ae3fc464563ad1ba59883ccf60d235b42f5ad7fa
08-01-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22646 Date: 2024-12-09 15:16:32 +0000
11-12-2024