Skip to content

Consistent null pointer value usage #3824

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3954,7 +3954,7 @@
Even if the size of the space
requested is zero, the request can fail. If the request succeeds, the
value returned by a replaceable allocation function
is a non-null pointer value\iref{conv.ptr}
is a non-null pointer value\iref{basic.compound}
\tcode{p0} different from any previously returned value \tcode{p1},
unless that value \tcode{p1} was subsequently passed to a
replaceable deallocation function.
Expand All @@ -3967,7 +3967,7 @@
to have \tcode{operator new()} implementable by
calling \tcode{std::malloc()} or \tcode{std::calloc()}, so the rules are
substantially the same. \Cpp{} differs from C in requiring a zero request
to return a non-null pointer.}
to return a non-null pointer value.}

\pnum
For an allocation function other than
Expand Down Expand Up @@ -4087,7 +4087,7 @@

\pnum
If the argument given to a deallocation function in the standard library
is a pointer that is not the null pointer value\iref{conv.ptr}, the
is a pointer that is not a null pointer value\iref{conv.ptr}, the
deallocation function shall deallocate the storage referenced by the
pointer, ending the duration of the region of storage.

Expand Down
22 changes: 11 additions & 11 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3492,7 +3492,7 @@
void h() {
F f;
A* ap = &f; // succeeds: finds unique \tcode{A}
D* dp = dynamic_cast<D*>(ap); // fails: yields null; \tcode{f} has two \tcode{D} subobjects
D* dp = dynamic_cast<D*>(ap); // fails: yields a null pointer value; \tcode{f} has two \tcode{D} subobjects
E* ep = (E*)ap; // error: cast from virtual base
E* ep1 = dynamic_cast<E*>(ap); // succeeds
}
Expand Down Expand Up @@ -4865,7 +4865,7 @@
\item
if the allocation function that would have been called
has a non-throwing exception specification\iref{except.spec},
the value of the \grammarterm{new-expression}
the result of the \grammarterm{new-expression}
is the null pointer value of the required result type;
\item
otherwise, the \grammarterm{new-expression} terminates by throwing an
Expand Down Expand Up @@ -5093,22 +5093,22 @@
\indexlibraryglobal{bad_alloc}%
\tcode{std::bad_alloc} exception~(\ref{basic.stc.dynamic.allocation},
\ref{except}, \ref{bad.alloc});
it returns a non-null pointer otherwise. If the allocation function
it returns a non-null pointer value otherwise. If the allocation function
has a non-throwing exception specification,
it returns null to indicate failure to allocate storage
and a non-null pointer otherwise.
it returns a null pointer value to indicate failure to allocate storage
and a non-null pointer value otherwise.
\end{note}
If the allocation function is a non-allocating
form\iref{new.delete.placement} that returns null,
form\iref{new.delete.placement} that returns a null pointer value,
the behavior is undefined.
Otherwise,
if the allocation function returns null, initialization shall not be
done, the deallocation function shall not be called, and the value of
the \grammarterm{new-expression} shall be null.
if the allocation function returns a null pointer value, initialization shall not be
done, the deallocation function shall not be called, and the result of
the \grammarterm{new-expression} shall be a null pointer value.

\pnum
\begin{note}
When the allocation function returns a value other than null, it must be
When the allocation function returns a non-null pointer value, it must be
a pointer to a block of storage in which space for the object has been
reserved. The block of storage is assumed to be appropriately aligned
and of the requested size. The address of the created object will not
Expand Down Expand Up @@ -6125,7 +6125,7 @@
considered to belong to a single-element array for this purpose.}
the result of the comparison is unspecified.
\item
Otherwise, if the pointers are both null, both point to the same
Otherwise, if both pointer values are null, both point to the same
\indextext{address}%
function, or both represent the same address\iref{basic.compound},
they compare equal.
Expand Down
50 changes: 25 additions & 25 deletions source/future.tex
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,10 @@
has a
\term{seekable area},
delimited by the pointers \tcode{seeklow} and \tcode{seekhigh}.
If \tcode{gnext} is a null pointer, the seekable area is undefined.
If \tcode{gnext} is a null pointer value, the seekable area is undefined.
Otherwise, \tcode{seeklow} equals \tcode{gbeg} and
\tcode{seekhigh} is either \tcode{pend},
if \tcode{pend} is not a null pointer, or \tcode{gend}.
if \tcode{pend} is a non-null pointer value, or \tcode{gend}.

\rSec3[depr.strstreambuf.cons]{\tcode{strstreambuf} constructors}

Expand All @@ -571,10 +571,10 @@
\begin{libtab2}{\tcode{strstreambuf(streamsize)} effects}{depr.strstreambuf.cons.sz}
{ll}
{Element}{Value}
\tcode{strmode} & \tcode{dynamic} \\
\tcode{alsize} & \tcode{alsize_arg} \\
\tcode{palloc} & a null pointer \\
\tcode{pfree} & a null pointer \\
\tcode{strmode} & \tcode{dynamic} \\
\tcode{alsize} & \tcode{alsize_arg} \\
\tcode{palloc} & a null pointer value \\
\tcode{pfree} & a null pointer value \\
\end{libtab2}

\indexlibraryctor{strstreambuf}%
Expand Down Expand Up @@ -621,8 +621,8 @@
{Element}{Value}
\tcode{strmode} & 0 \\
\tcode{alsize} & an unspecified value \\
\tcode{palloc} & a null pointer \\
\tcode{pfree} & a null pointer \\
\tcode{palloc} & a null pointer value \\
\tcode{pfree} & a null pointer value \\
\end{libtab2}

\pnum
Expand Down Expand Up @@ -651,7 +651,7 @@
\end{itemize}

\pnum
If \tcode{pbeg_arg} is a null pointer, the function executes:
If \tcode{pbeg_arg} is a null pointer value, the function executes:

\begin{codeblock}
setg(gnext_arg, gnext_arg, gnext_arg + N);
Expand Down Expand Up @@ -734,7 +734,7 @@

\pnum
\remarks
The return value can be a null pointer.
The return value can be a null pointer value.
\end{itemdescr}

\indexlibrarymember{pcount}{strstreambuf}%
Expand All @@ -746,7 +746,7 @@
\pnum
\effects
If the next pointer for the output sequence, \tcode{pnext}, is
a null pointer, returns zero.
a null pointer value, returns zero.
Otherwise, returns the current
effective length of the array object as the next pointer minus the beginning
pointer for the output sequence, \tcode{pnext - pbeg}.
Expand Down Expand Up @@ -806,7 +806,7 @@
\indextext{unspecified}%
\footnote{An implementation should consider \tcode{alsize} in making this
decision.}
If \tcode{palloc} is not a null pointer, the function calls
If \tcode{palloc} is a non-null pointer value, the function calls
\tcode{(*palloc)(n)}
to allocate the new dynamic array object.
Otherwise, it evaluates the expression
Expand All @@ -818,7 +818,7 @@
\pnum
To free a previously existing dynamic array object whose first
element address is \tcode{p}:
If \tcode{pfree} is not a null pointer,
If \tcode{pfree} is a non-null pointer value,
the function calls
\tcode{(*pfree)(p)}.
Otherwise, it evaluates the expression \tcode{delete[]p}.
Expand Down Expand Up @@ -905,7 +905,7 @@
\tcode{(unsigned char)\brk*gnext}.
\item
Otherwise, if
the current write next pointer \tcode{pnext} is not a null pointer and
the current write next pointer \tcode{pnext} is a non-null pointer value and
is greater than the current read end pointer \tcode{gend},
makes a
\term{read position}
Expand Down Expand Up @@ -955,7 +955,7 @@
\end{libtab2}

\pnum
For a sequence to be positioned, if its next pointer is a null pointer,
For a sequence to be positioned, if its next pointer is a null pointer value,
the positioning operation fails.
Otherwise, the function determines \tcode{newoff} as indicated in
\tref{depr.strstreambuf.seekoff.newoff}.
Expand Down Expand Up @@ -1018,7 +1018,7 @@
\end{itemize}

\pnum
For a sequence to be positioned, if its next pointer is a null pointer,
For a sequence to be positioned, if its next pointer is a null pointer value,
the positioning operation fails.
Otherwise, the function determines \tcode{newoff} from
\tcode{sp.offset()}:
Expand Down Expand Up @@ -1727,7 +1727,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null.
\requires \tcode{p} shall be a non-null pointer value.

\pnum
\returns
Expand All @@ -1745,7 +1745,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null.
\requires \tcode{p} shall be a non-null pointer value.

\pnum
\returns
Expand All @@ -1763,7 +1763,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null.
\requires \tcode{p} shall be a non-null pointer value.

\pnum
\requires \tcode{mo} shall not be \tcode{memory_order_release} or \tcode{memory_order_acq_rel}.
Expand All @@ -1784,7 +1784,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null.
\requires \tcode{p} shall be a non-null pointer value.

\pnum
\effects
Expand All @@ -1802,7 +1802,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null.
\requires \tcode{p} shall be a non-null pointer value.

\pnum
\requires \tcode{mo} shall not be \tcode{memory_order_acquire} or \tcode{memory_order_acq_rel}.
Expand All @@ -1823,7 +1823,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null.
\requires \tcode{p} shall be a non-null pointer value

\pnum
\returns
Expand All @@ -1842,7 +1842,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null.
\requires \tcode{p} shall be a non-null pointer value.

\pnum
\effects
Expand All @@ -1865,7 +1865,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null and \tcode{v} shall not be null.
\requires \tcode{p} and \tcode{v} shall be non-null pointer values.

\pnum
\returns
Expand Down Expand Up @@ -1907,7 +1907,7 @@

\begin{itemdescr}
\pnum
\requires \tcode{p} shall not be null and \tcode{v} shall not be null.
\requires \tcode{p} and \tcode{v} shall be non-null pointer values.
The \tcode{failure} argument shall not be \tcode{memory_order_release} nor
\tcode{memory_order_acq_rel}.

Expand Down
Loading