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

The wording in [dcl.fct.def.general]/2 doesn't seem to be right. #4604

Closed
AlexanderMace opened this issue May 18, 2021 · 6 comments
Closed

Comments

@AlexanderMace
Copy link

[dcl.fct.def.general]/2:

In a function-definition, either void declarator ; or declarator ; shall be a well-formed function declaration
as described in [dcl.fct].
A function shall be defined only in namespace or class scope. The type of a parameter or the return type for a function definition shall not be a (possibly cv-qualified) class type that is incomplete or abstract within the function body unless the function is deleted ([dcl.fct.def.delete]).

What does the sentence highlighted above has to do with the fact that a parenthesized declarator should be accepted in a function-definition? See DR2145 about this.

See also my question in SO and this comment by T.C..

@jensmaurer
Copy link
Member

A declarator may be parenthesized as described in [dcl.meaning.general] p8.

Therefore, this sentence ensures that parenthesized declarators are allowed.

@AlexanderMace
Copy link
Author

AlexanderMace commented May 18, 2021

"A declarator may be parenthesized as described in [dcl.meaning.general] p8."

[dcl.fct.def.general]/2 is about declarator, but [dcl.meaning.general]/8 is about declarator-id not declarator.

"Therefore, this sentence ensures that parenthesized declarators are allowed."

I simply cannot understand the relationship between the alluded sentence and what you wrote above. Could you elaborate?

@jensmaurer
Copy link
Member

[dcl.meaning.general] p8 "In a declaration T D where D has the form ..."

Compare with [dcl.meaning.general] p5, which says that "D" is a declarator. Note that p8 talks about the declarator-id (possibly deep) inside D and assumes the understanding of p5.

@AlexanderMace
Copy link
Author

"Compare with [dcl.meaning.general] p5, which says that "D" is a declarator. Note that p8 talks about the declarator-id (possibly deep) inside D and assumes the understanding of p5."

Ok, I can accept this. But how does the sentence highlighted in my first post ensure that parenthesized declarators are allowed?

@jensmaurer
Copy link
Member

Because it says that "T declarator" (with T=void or absent), with the declarator from the constructor grammar, must be a valid function declaration. In order to analyze this, you need to iterate through [dcl.meaning], which (among other things) takes care of "T (declarator)".

@AlexanderMace
Copy link
Author

In a function-definition, either void declarator ; or declarator ; shall be a well-formed function declaration
as described in [dcl.fct].

It definitely doesn't tell me anything. I'm giving up !

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