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
[conv.ptr] Fix unclear specification of derived-to-base conversions for null pointers #3823
base: main
Are you sure you want to change the base?
Conversation
source/expressions.tex
Outdated
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 value is a null pointer value, the result is a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the "source value"? Can we reformulate without using this novel term?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jensmaurer In [conv], there's a mixture of "source value", "source expression" and "source prvalue". I suppose that the best replacement here would be "source prvalue".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better, because it aligns with the phrasing in the "If" at the start of the paragraph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jensmaurer Applied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like using "source prvalue" here. A prvalue is a kind of expression, so this sounds like it's talking about a (static) property of the expression, which it's not.
I think something like "A null pointer value of the source type is converted to a null pointer value of the destination type. A pointer to an object o of type D
is converted to a pointer to the B
base class subobject of o." would work, and fits much better into our pointer value taxonomy in [basic.compound]. Arguably this would need CWG review since it makes it much more clear that such a conversion applied to any other pointer value is undefined.
@jensmaurer I applied the changes in [conv.ptr] to [conv.mem], [expr.static.cast], [expr.reinterpret.cast], and [expr.const.cast]. Another small error I fixed was that in [conv.mem] we say "The result refers to the member in |
@sdkrystian, could you please rebase and implement @zygoloid's suggestion, which sounds like an improvement? |
[conv.ptr] p3 states:
While null pointer values are established as a singular value a pointer can have in [basic.compound], it is unique to the pointer type. Saying "The null pointer value" is rather unclear in what it refers to, as there is no single null pointer value.