Skip to content

Commit 79e84e1

Browse files
committed
New issue from Janet Cobb: "Definition of NULL is too broad"
1 parent c1375f1 commit 79e84e1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

xml/issue4182.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4182" status="New">
5+
<title>Definition of `NULL` is too broad</title>
6+
<section><sref ref="[support.types.nullptr]"/></section>
7+
<submitter>Janet Cobb</submitter>
8+
<date>09 Dec 2024</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
<sref ref="[conv.ptr]"/>/1 reads in part: "A <i>null pointer constant</i> is an integer literal (<sref ref="[lex.icon]"/>)
14+
with value zero or a prvalue of type `std::nullptr_t`.".
15+
<p/>
16+
<sref ref="[support.types.nullptr]"/>/2 reads: "The macro `NULL` is an implementation-defined null pointer constant.".
17+
<p/>
18+
Together, these imply that `#define NULL (::std::unreachable(), nullptr)` is a conforming definition. The expression is
19+
a prvalue of type `std::nullptr_t`, so it is a null pointer constant. This makes it implementation-defined whether
20+
any program that evaluates `NULL` has undefined behavior.
21+
</p>
22+
</discussion>
23+
24+
<resolution>
25+
<p>
26+
This wording is relative to <paper num="N5001"/>.
27+
</p>
28+
29+
30+
<ol>
31+
<li><p>Modify <sref ref="[support.types.nullptr]"/> as indicated:</p>
32+
33+
<blockquote>
34+
<p>
35+
-2- The macro `NULL` is an implementation-defined null pointer constant <ins>that is a literal
36+
(<sref ref="[lex.icon]"/>, <sref ref="[lex.nullptr]"/>)</ins>.<sup>footnote 161</sup>
37+
<p/>
38+
<small>161) Possible definitions include `0` and `0L`, but not `(void*)0`.</small>
39+
</p>
40+
</blockquote>
41+
42+
</li>
43+
44+
</ol>
45+
</resolution>
46+
47+
</issue>

0 commit comments

Comments
 (0)