Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8327173: HotSpot Style Guide needs update regarding nullptr vs NULL #18101

Closed
wants to merge 3 commits into from

Conversation

kimbarrett
Copy link

@kimbarrett kimbarrett commented Mar 4, 2024

Please review this change to update the HotSpot Style Guide's discussion of
nullptr and its use.

I suggest this is an editorial rather than substantive change to the style
guide. As such, the normal HotSpot PR process can be used for this change.


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

Issue

  • JDK-8327173: HotSpot Style Guide needs update regarding nullptr vs NULL (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18101

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 4, 2024

👋 Welcome back kbarrett! 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 added the rfr Pull request is ready for review label Mar 4, 2024
@openjdk
Copy link

openjdk bot commented Mar 4, 2024

@kimbarrett The following labels will be automatically applied to this pull request:

  • build
  • hotspot

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

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org build build-dev@openjdk.org labels Mar 4, 2024
([n2431](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf))
to `NULL`. Don't use (constexpr or literal) 0 for pointers.
rather than `NULL`. Don't use (constant expression or literal) 0 for pointers.
Copy link
Author

@kimbarrett kimbarrett Mar 4, 2024

Choose a reason for hiding this comment

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

Should there be any discussion here of why we want to avoid NULL? Specifically the varying
definitions and the pitfalls of NULL in varargs context. Also template and overload issues.

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be enough to write 1..2 sentences about this, and then defer to N2431 already linked here for more details.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Aleksey.

Copy link
Author

Choose a reason for hiding this comment

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

Good point. I decided just referring to the paper for rationale is sufficient.

@mlbridge
Copy link

mlbridge bot commented Mar 4, 2024

Webrevs

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Looks okay, but questions/suggestions:

([n2431](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf))
to `NULL`. Don't use (constexpr or literal) 0 for pointers.
rather than `NULL`. Don't use (constant expression or literal) 0 for pointers.
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be enough to write 1..2 sentences about this, and then defer to N2431 already linked here for more details.

Comment on lines 735 to 738
The C++11 definition of _null pointer constant_ included integral constant
expressions with value zero. C++14 replaced that with integer literals with
value zero. Some compilers continue to treat a zero-valued integral constant
expressions as a _null pointer constant_ even in C++14 mode.
Copy link
Member

Choose a reason for hiding this comment

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

It is not very clear why should this concern any Hotspot developers?

Copy link
Author

Choose a reason for hiding this comment

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

If one is familiar with C++14 (or later) or were to look up null pointer
constant
in the C++14 standard, one might wonder why this style guide
admonishes against using non-literal constant expressions for such. But I've
rewritten the part about 0 as a pointer to (I think) make things clearer.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Current revised text looks good to me.

Thanks

@openjdk
Copy link

openjdk bot commented Mar 5, 2024

@kimbarrett 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:

8327173: HotSpot Style Guide needs update regarding nullptr vs NULL

Reviewed-by: shade, dholmes, kvn

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 added the ready Pull request is ready to be integrated label Mar 5, 2024
@kimbarrett
Copy link
Author

I just discovered gcc -Wzero-as-null-pointer-constant. We might be able to make some quick progress on those
legacy uses of 0 pointers.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Approved.

@kimbarrett
Copy link
Author

Thanks for reviews @vnkozlov , @kimbarrett , and @dholmes-ora .

@kimbarrett
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 6, 2024

Going to push as commit 3d37b28.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 6, 2024
@openjdk openjdk bot closed this Mar 6, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 6, 2024
@openjdk
Copy link

openjdk bot commented Mar 6, 2024

@kimbarrett Pushed as commit 3d37b28.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kimbarrett kimbarrett deleted the nullptr-style branch March 6, 2024 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants