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

[class.dtor] p1 Make the requirement of a prospective destructor to be accurate. #5421

Open
xmh0511 opened this issue Apr 27, 2022 · 4 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Apr 27, 2022

[class.dtor] p1 says

A prospective destructor shall take no arguments ([dcl.fct]).

[dcl.fct] p4 says

If the parameter-declaration-clause is empty, the function takes no arguments.

Taking no arguments does not mean the parameter-declaration-clause is empty. I think

The parameter-declaration-clause of a prospective destructor shall be empty

is the intent here.

struct A{
   ~A(void){} // ok
};

A parameter list consisting of a single unnamed parameter of non-dependent type void is equivalent to an empty parameter list.

@jensmaurer
Copy link
Member

I don't want to refer to a grammar term, decree that it "shall be empty", and then rely on an "equivalent" phrasing somewhere to justify that it nonetheless might not actually consist of zero tokens.

Maybe we should say "the parameter list shall be empty" or so, and have dcl.fct clearly define "parameter list". Maybe "parameter-type-list" is a term which would fit here.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Apr 27, 2022

I think we should define the term "parameter list", which is a list that comprises each parameter introduced by the corresponding declaration in parameter-declaration-clause, In other words, the sequence of parameters. "parameter-type-list" is the sequence of the (adjusted)types of the parameters. The former is more suitable here since we are only concerned about whether the destructor has parameters. Instead, the latter is defined as producing types.

@jensmaurer
Copy link
Member

parameter-type-list also represents the presence or absence of the va_args ellipsis, I think.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Apr 28, 2022

Anyway, a parameter list can also represent the ellipsis(syntactically, it's , ...). It might make the intent clear that we separate the parameters from parameters' types. The definition of "parameter list" might be

A parameter list consists of each parameter introduced by parameter-declaration and ... that is part of parameter-declaration-clause(if any).

And we have said that

A parameter list consisting of a single unnamed parameter of non-dependent type void is equivalent to an empty parameter list.

So, we rule that the parameter list of a prospective destructor shall be empty, which clearly means

  • either its parameter-declaration-clause consists of zero token, or
  • its parameter-declaration-clause is just void.

I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants