Skip to content
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

Do destructors have names? #414

Closed
cpplearner opened this issue Nov 30, 2014 · 6 comments
Closed

Do destructors have names? #414

cpplearner opened this issue Nov 30, 2014 · 6 comments
Labels
cwg Issue must be reviewed by CWG.

Comments

@cpplearner
Copy link
Contributor

N4296 7.3.3 [namespace.udecl]/4 says Since destructors do not have names, a using-declaration cannot refer to a destructor for a base class. But 12.4 [class.dtor]/13 mentions "the destructor name" (in the sentence In an explicit destructor call, the destructor name appears as a ~ followed by a type-name or decltype-specifier that denotes the destructor’s class type.)

So, do destructors have names or not?

@jwakely
Copy link
Member

jwakely commented Nov 30, 2014

@zygoloid, is this non-editorial? It seems like "the destructor name" could be changed to talk about the id-expression in a postfix expression, except that [expr.call] says that has to be a function member name, and the destructor doesn't have a name:

For a member function call, the postfix expression shall be an implicit (9.3.1, 9.4) or explicit class member access (5.2.5) whose id-expression is a function member name, or a pointer-to-member expression (5.5) selecting a function member.

This makes me think of the White Knight explaining that "The song's name is called Haddocks' Eyes".

@cpplearner
Copy link
Contributor Author

If I'm not mistaken, a qualified-id is not a name, therefore that sentence is in itself erroneous.

For the same reason, I think that the grammar term pseudo-destructor-name is poorly named. If ~class-name and ~ decltype-specifier are really not names, then pseudo-destructor-name is nothing similar to a name.

@FrankHB
Copy link
Contributor

FrankHB commented Dec 7, 2014

3/4 A name is a use of an identifier (2.11), operator-function-id (13.5), literal-operator-id (13.5.8), conversion-function-id (12.3.2), or template-id (14.2) that denotes an entity or label (6.6.4, 6.1).

Certain _use_s of some kinds of unqualified-id above are considered as names. "~ class-name" is unqualified-id, but not listed here.

What does "use" precisely mean?

@zygoloid
Copy link
Member

We have a precise definition for "name", but we don't stick to it. For instance:

[basic.def.odr]p3: "A variable whose name appears as a potentially-evaluated expression ex is odr-used by ex unless [...]"
This presumably means "A potentially-evaluated id-expression ex that refers to a variable x odr-uses x unless [...]"
But according to the definition of "name", the id-expression need not refer to the variable x; it can refer to another variable in a different declarative region that merely has the same identifier as its name!

Later on in p6, we have the same problem; the ODR doesn't take the declarative region of the entity into account.

And so on. We really need a comprehensive study of where "name" is used and misused.

I've forwarded this to CWG for discussion as to how best to proceed.

@zygoloid zygoloid added the cwg Issue must be reviewed by CWG. label Jan 13, 2015
@tkoeppe
Copy link
Contributor

tkoeppe commented Jun 23, 2016

This is obsolete, the wording has been fixed. It now says "the destructor is specified by a ~ followed by ..."

@cpplearner
Copy link
Contributor Author

Fixed by CWG 2069.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

No branches or pull requests

5 participants