-
Notifications
You must be signed in to change notification settings - Fork 763
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
[basic.lval,expr.delete] 'dynamic type' refers to lvalues, not objects #2265
base: main
Are you sure you want to change the base?
Conversation
I don't really like the edits to [expr.delete]. The issue here is that the operand of the delete-expression is a pointer, but "dynamic type" is only defined for lvalues. We can either add a definition of "dynamic type" for pointers (deferring to the glvalue case), or we can locally construct an lvalue in [expr.delete]. I've done the latter, but I'm not totally happy with it. Comments welcome; in particular the [basic.lval] rewrites are rather extensive. |
... and while we're at it, the definition of "dynamic type" seems to belong to [expr.prop], since it's a property of an expression. |
\grammarterm{delete-expression}\iref{class.free}. | ||
This assures that a deallocation function | ||
is available for a \grammarterm{delete-expression}\iref{class.free}, | ||
even if the static type of the object to which the operand points |
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.
"static type" is also a property of an expression :(
http://eel.is/c++draft/intro.defs#defns.static.type
source/expressions.tex
Outdated
expression, if the dynamic type of the object to be deleted differs from its | ||
static type, the behavior is undefined. | ||
the static type shall be | ||
a base class of the dynamic type of the object to be deleted |
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.
"dynamic type" still refers to the object here.
Editorial meeting: Maybe replace "dynamic type" simply with "most derived type of the object the glvalue / pointer refers to". Well, no, "dynamic type" is too ingrained in the history of C++. "... even if the pointer points to a base class subobject." "assures" -> "ensures" |
source/expressions.tex
Outdated
undefined:\footnote{The intent of this list is to specify those circumstances in which an | ||
object may or may not be aliased.} | ||
If a program attempts to access the stored value of an object of type \tcode{T} | ||
through a glvalue whose dynamic type is not one of the following types, |
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.
use "static type" here
source/expressions.tex
Outdated
|
||
\item a type that is the signed or unsigned type corresponding to a | ||
cv-qualified version of the dynamic type of the object, | ||
\item a type that is the signed or unsigned type corresponding to \cv{} \tcode{T}, | ||
|
||
\item an aggregate or union type that includes one of the aforementioned types among its | ||
elements or non-static data members (including, recursively, an element or non-static data member of a | ||
subaggregate or contained union), |
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.
This is useless in C++, except for the copy of a union. Oh, covered by the final bullet, which covers object representations = arrays of unsigned char.
@@ -2875,10 +2865,10 @@ | |||
of the object expression is called; such a call is referred to as a | |||
\defnx{virtual function call}{function!virtual function call}. | |||
\begin{note} | |||
The dynamic type is the type of the object referred to by the | |||
current value of the object expression. \ref{class.cdtor}~describes the | |||
behavior of virtual function calls when the object expression |
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.
Simply strike the first sentence of the note instead of trying to fix it.
Editorial issue: Changes to [basic.lval] collide with CWG 2051. |
@jensmaurer: Rebase? |
@tkoeppe, this needs (a lot) more work than a simple rebase. Not right now. |
@jensmaurer: Is there still something left to pursue here? |
Yes, I think this needs a bit of love + care at some later point. There is a terminological haziness around "static type" and "dynamic type" that ought to be fixed, possibly by eradicating "static type" entirely (it's simply the type of the expression) and doing some goodness to "dynamic type". After all, "dynamic type" means "type of the (most derived) object" (unrelated to any specific expression), but "static type" means "type of the expression as written in the source and specified by [expr]". Crazy talk such as "the static type of the object to be deleted" just needs to go; talking about the static type of an object is a category error as explained above. |
Fixes #2190.