Skip to content

Commit

Permalink
8327173: HotSpot Style Guide needs update regarding nullptr vs NULL
Browse files Browse the repository at this point in the history
Reviewed-by: shade, dholmes, kvn
  • Loading branch information
Kim Barrett committed Mar 6, 2024
1 parent 989fc3e commit 3d37b28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 8 additions & 5 deletions doc/hotspot-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,15 @@ <h3 id="thread_local">thread_local</h3>
href="https://bugs.openjdk.org/browse/JDK-8282469">JDK-8282469</a> for
further discussion.</p>
<h3 id="nullptr">nullptr</h3>
<p>Prefer <code>nullptr</code> (<a
<p>Use <code>nullptr</code> (<a
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf">n2431</a>)
to <code>NULL</code>. Don't use (constexpr or literal) 0 for
pointers.</p>
<p>For historical reasons there are widespread uses of both
<code>NULL</code> and of integer 0 as a pointer value.</p>
rather than <code>NULL</code>. See the paper for reasons to avoid
<code>NULL</code>.</p>
<p>Don't use (constant expression or literal) 0 for pointers. Note that
C++14 removed non-literal 0 constants from <em>null pointer
constants</em>, though some compilers continue to treat them as such.
For historical reasons there may be lingering uses of 0 as a
pointer.</p>
<h3 id="atomic">&lt;atomic&gt;</h3>
<p>Do not use facilities provided by the <code>&lt;atomic&gt;</code>
header (<a
Expand Down
10 changes: 6 additions & 4 deletions doc/hotspot-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,14 @@ for further discussion.

### nullptr

Prefer `nullptr`
Use `nullptr`
([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`. See the paper for reasons to avoid `NULL`.

For historical reasons there are widespread uses of both `NULL` and of
integer 0 as a pointer value.
Don't use (constant expression or literal) 0 for pointers. Note that C++14
removed non-literal 0 constants from _null pointer constants_, though some
compilers continue to treat them as such. For historical reasons there may be
lingering uses of 0 as a pointer.

### &lt;atomic&gt;

Expand Down

1 comment on commit 3d37b28

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.