Skip to content

[conv.ptr] Fix unclear specification of derived-to-base conversions for null pointers #3823

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
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
29 changes: 15 additions & 14 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,10 @@
of \tcode{D}. If \tcode{B} is an
inaccessible\iref{class.access} or
ambiguous\iref{class.member.lookup} base class of \tcode{D}, a program
that necessitates this conversion is ill-formed. The result of the
conversion is a pointer to the base class subobject of the derived class
object. The null pointer value is converted to the null pointer value of
the destination type.
that necessitates this conversion is ill-formed.
If the source prvalue is a null pointer value, the result is a
null pointer value; otherwise, the result is a pointer to the
base class subobject of the derived class object.

\rSec2[conv.mem]{Pointer-to-member conversions}

Expand Down Expand Up @@ -1021,14 +1021,15 @@
\tcode{D}, a program that necessitates this conversion is ill-formed.
The result of the conversion refers to the same member as the pointer to
member before the conversion took place, but it refers to the base class
member as if it were a member of the derived class. The result refers to
the member in \tcode{D}'s instance of \tcode{B}. Since the result has
member as if it were a member of the derived class. If the source prvalue
is a null member pointer value, the result is a null member pointer value;
otherwise, the result refers to the member in the \tcode{B}
base class subobject of \tcode{D}. Since the result has
type ``pointer to member of \tcode{D} of type \cv{} \tcode{T}'',
indirection through it with a \tcode{D} object is valid. The result is the same
as if indirecting through the pointer to member of \tcode{B} with the
\tcode{B} subobject of \tcode{D}. The null member pointer value is
converted to the null member pointer value of the destination
type.\footnote{The rule for conversion of pointers to members (from pointer to member
\tcode{B} subobject of \tcode{D}.
\footnote{The rule for conversion of pointers to members (from pointer to member
of base to pointer to member of derived) appears inverted compared to
the rule for pointers to objects (from pointer to derived to pointer to
base)~(\ref{conv.ptr}, \ref{class.derived}). This inversion is
Expand Down Expand Up @@ -3772,7 +3773,7 @@
a base class of a virtual base class of \tcode{D}, or
if no valid standard conversion from ``pointer to \tcode{D}''
to ``pointer to \tcode{B}'' exists\iref{conv.ptr}, the program is ill-formed.
The null pointer value\iref{conv.ptr} is converted
A null pointer value\iref{conv.ptr} is converted
to the null pointer value of the destination type. If the prvalue of type
``pointer to \cvqual{cv1} \tcode{B}'' points to a \tcode{B} that is
actually a subobject of an object of type \tcode{D}, the resulting
Expand All @@ -3796,7 +3797,7 @@
from ``pointer to member of \tcode{B} of type \tcode{T}''
to ``pointer to member of \tcode{D} of type \tcode{T}''
exists\iref{conv.mem}, the program is ill-formed.
The null member pointer value\iref{conv.mem} is converted to the null
A null member pointer value\iref{conv.mem} is converted to the null
member pointer value of the destination type. If class \tcode{B}
contains the original member, or is a base or derived class of the class
containing the original member, the resulting pointer to member points
Expand Down Expand Up @@ -3943,7 +3944,7 @@
pointer value.

\pnum
The null pointer value\iref{conv.ptr} is converted to the null pointer value
A null pointer value\iref{conv.ptr} is converted to the null pointer value
of the destination type.
\begin{note}
A null pointer constant of type \tcode{std::nullptr_t} cannot be converted to a
Expand All @@ -3960,7 +3961,7 @@
function types or both object types.\footnote{\tcode{T1} and \tcode{T2} may have
different \cv-qualifiers, subject to
the overall restriction that a \tcode{reinterpret_cast} cannot cast away
constness.} The null member pointer value\iref{conv.mem} is converted to the
constness.} A null member pointer value\iref{conv.mem} is converted to the
null member pointer value of the destination type. The result of this
conversion is unspecified, except in the following cases:

Expand Down Expand Up @@ -4057,7 +4058,7 @@

\pnum
A null pointer value\iref{conv.ptr} is converted to the null pointer
value of the destination type. The null member pointer
value of the destination type. A null member pointer
value\iref{conv.mem} is converted to the null member pointer value of
the destination type.

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy