Skip to content

8388923: Avoid local initialized unused variables in Hotspot - #32039

Open
MBaesken wants to merge 1 commit into
openjdk:masterfrom
MBaesken:JDK-8388923
Open

8388923: Avoid local initialized unused variables in Hotspot#32039
MBaesken wants to merge 1 commit into
openjdk:masterfrom
MBaesken:JDK-8388923

Conversation

@MBaesken

@MBaesken MBaesken commented Jul 24, 2026

Copy link
Copy Markdown
Member

While testing the MSVC warning flag for local initialized unused variables, a couple of places in the HS codebase were found.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8388923: Avoid local initialized unused variables in Hotspot (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32039/head:pull/32039
$ git checkout pull/32039

Update a local copy of the PR:
$ git checkout pull/32039
$ git pull https://git.openjdk.org/jdk.git pull/32039/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 32039

View PR using the GUI difftool:
$ git pr show -t 32039

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32039.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jul 24, 2026

Copy link
Copy Markdown

👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jul 24, 2026

Copy link
Copy Markdown

@MBaesken This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8388923: Avoid local initialized unused variables in Hotspot

Reviewed-by: amitkumar, aph

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1 new commit pushed to the master branch:

  • e0f6001: 8388543: AArch64: VectorAPI: replace sve_dup+mov with fmovd in sve_vmask_fromlong

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk Bot changed the title JDK-8388923: Avoid local initialized unused variables in Hotspot 8388923: Avoid local initialized unused variables in Hotspot Jul 24, 2026
@openjdk openjdk Bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jul 24, 2026
@openjdk

openjdk Bot commented Jul 24, 2026

Copy link
Copy Markdown

@MBaesken The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk

openjdk Bot commented Jul 24, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-compiler. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Jul 24, 2026
@mlbridge

mlbridge Bot commented Jul 24, 2026

Copy link
Copy Markdown

Webrevs

@offamitkumar offamitkumar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@offamitkumar

offamitkumar commented Jul 24, 2026

Copy link
Copy Markdown
Member

Matthias any thoughts why gcc is clueless about unused variable ? I passed -Wunused-variable -Wunused-but-set-variable still It caught nothing.

Edit: I ran it on master branch, it wasn't even able to detect the unused variable removed by this PR.

@theRealAph theRealAph left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a useful cleanup.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jul 24, 2026
@MBaesken

Copy link
Copy Markdown
Member Author

Matthias any thoughts why gcc is clueless about unused variable ? I passed -Wunused-variable -Wunused-but-set-variable still It caught nothing.

Edit: I ran it on master branch, it wasn't even able to detect the unused variable removed by this PR.

Not sure, but we explicitly disable some unused vars warnings for Hotspot when using gcc/clang, see the DISABLED_WARNINGS_gcc settings in
https://github.com/openjdk/jdk/blob/master/make/hotspot/lib/CompileJvm.gmk#L102

Reason might be, that we have LOTS and LOTS of coding in Hotspot, where we set some variable that is later only used in debug-coding (e.g. the many asserts that have been introduced in Hotspot). So product builds would fail with such warnings set.
With C++17 and current Hotspot guidelines, it seems we have now [[maybe_unused]] to flag such variables, but it would still be quite a lot of work and I am unsure how 'popular' this [[maybe_unused]] flagging would be among Hotspot developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants