Skip to content

8378180: Compiling OpenJDK with C23 C-Compiler gives warning: initialization discards ‘const’ qualifier from pointer target type#3231

Open
fthevenet wants to merge 2 commits into
openjdk:masterfrom
fthevenet:backport-16971af1
Open

8378180: Compiling OpenJDK with C23 C-Compiler gives warning: initialization discards ‘const’ qualifier from pointer target type#3231
fthevenet wants to merge 2 commits into
openjdk:masterfrom
fthevenet:backport-16971af1

Conversation

@fthevenet

@fthevenet fthevenet commented Jun 26, 2026

Copy link
Copy Markdown
Member

This is an unclean backport of of commit 16971af1 from the openjdk/jdk17u-dev repository (itslef a backport of 76a44b3e from openjdk/jdk).

The aim for this backport is to address compiler warnings that arise when attempting to build with with more recent version of gcc (16.1+).

The patch does not appy cleanly; the following modifications were necessary:

  • Ignore the changes to src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c as the file doesn't exists in jdk11
  • The changes in src/java.base/unix/native/libnet/NetworkInterface.c are not applicaple to jdk11 (*colonP is assigned a value at line 251, cannot be declared const) (EDIT: This PR also includes a backport of JDK-8254871, making the changes to src/java.base/unix/native/libnet/NetworkInterface.c relevant)
  • A change not included in the original patch is required to prevent a discarded-qualifiers warning in src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c

I have verified that with this patch, jdk11u-dev compiles without warning on Fedora 44 with gcc 16.1.1.



Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8378180 needs maintainer approval
  • JDK-8254871 needs maintainer approval

Issues

  • JDK-8378180: Compiling OpenJDK with C23 C-Compiler gives warning: initialization discards ‘const’ qualifier from pointer target type (Enhancement - P3 - Requested)
  • JDK-8254871: Remove unnecessary string copy in NetworkInterface.c (Task - P4 - Requested)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk11u-dev.git pull/3231/head:pull/3231
$ git checkout pull/3231

Update a local copy of the PR:
$ git checkout pull/3231
$ git pull https://git.openjdk.org/jdk11u-dev.git pull/3231/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3231

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk11u-dev/pull/3231.diff

Using Webrev

Link to Webrev Comment

@fthevenet fthevenet marked this pull request as draft June 26, 2026 15:18
@bridgekeeper

bridgekeeper Bot commented Jun 26, 2026

Copy link
Copy Markdown

👋 Welcome back fthevenet! 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 Jun 26, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot changed the title backport 16971af10713a9ddd142532845ac58649cf2f970 8378180: Compiling OpenJDK with C23 C-Compiler gives warning: initialization discards ‘const’ qualifier from pointer target type Jun 26, 2026
@openjdk

openjdk Bot commented Jun 26, 2026

Copy link
Copy Markdown

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk Bot added the backport Port of a pull request already in a different code base label Jun 26, 2026
@fthevenet fthevenet marked this pull request as ready for review June 26, 2026 16:29
@openjdk openjdk Bot added the rfr Pull request is ready for review label Jun 26, 2026
@mlbridge

mlbridge Bot commented Jun 26, 2026

Copy link
Copy Markdown

Webrevs

@vieiro

vieiro commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Builds in RHEL-8 / gcc 8.5.0 and Fedora 43/ gcc 15.2.1 run fine.

@fthevenet

Copy link
Copy Markdown
Member Author

Thanks for testing this @vieiro

@tstuefe tstuefe 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.

ok

@openjdk

openjdk Bot commented Jul 2, 2026

Copy link
Copy Markdown

⚠️ @fthevenet This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@fthevenet

Copy link
Copy Markdown
Member Author

Thanks for the review @tstuefe

@fthevenet

fthevenet commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

/approval request I'd like to backport this to JDK 11.

Motivation: This patch is needed in order to build jdk11u with more recent version of gcc (16.1.1+), as it fixes compiler warnings.

The patch does not appy cleanly; the following modifications are necessary:

  • Ignore the changes to src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c as the file doesn't exists in jdk11
  • A change not included in the original patch is required to prevent a discarded-qualifiers warning in src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c

The change introduces no behaviour change and is low risk.

I have verified that with this patch, jdk11u-dev compiles without warning on Fedora 44 with gcc 16.1.1.

@openjdk

openjdk Bot commented Jul 2, 2026

Copy link
Copy Markdown

@fthevenet
8378180: The approval request has been created successfully.

@openjdk openjdk Bot added the approval Requires approval; will be removed when approval is received label Jul 2, 2026

@gnu-andrew gnu-andrew 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.

  • Copyright header adjustments look fine.
  • No issue dropping LinuxPackage.c changes
  • socketTransport.c changes were part of a enhancement with CSR in 13, JDK-8223104: "JDWP support for IPv6", so ok just bringing that one line change over.
  • The need for the NetworkInterface.c change is JDK-8254871: "Remove unnecessary string copy in NetworkInterface.c" which looks a small enough change to backport as a pre-requisite of this. This change both removes a redundant string copy and the need to reassign to colonP.

The change is small enough that you could add it as an extra commit here followed by the missing part of 8254871. Just make sure to credit the additional issue with /issue add if you go that route.

@fthevenet

Copy link
Copy Markdown
Member Author

/issue add JDK-8254871

@openjdk

openjdk Bot commented Jul 7, 2026

Copy link
Copy Markdown

@fthevenet
Adding additional issue to issue list: 8254871: Remove unnecessary string copy in NetworkInterface.c.

@fthevenet

Copy link
Copy Markdown
Member Author

Thanks for the review @gnu-andrew
I have done as you suggested and brought in the changes from JDK-8254871 into this PR.

@fthevenet

Copy link
Copy Markdown
Member Author

/approval JDK-8254871 request I'd like to backport this to JDK 11.

The main motivation for this patch is as a prerequisite for backporting JDK-8378180

The patch applies cleanly.

@openjdk

openjdk Bot commented Jul 7, 2026

Copy link
Copy Markdown

@fthevenet
JDK-8254871: The approval request has been created successfully.

@gnu-andrew gnu-andrew 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.

Thanks for backporting the additional fix. I confirmed the new commit is 8254871 + the missing changes from 8378180.

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

Labels

approval Requires approval; will be removed when approval is received backport Port of a pull request already in a different code base rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

4 participants