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

[stmt.pre] Different definitions for the substatements of selection-statement and iteration-statement #4468

Closed
xmh0511 opened this issue Jan 21, 2021 · 2 comments · Fixed by #4485
Assignees

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jan 21, 2021

The definition for substatements of a selection-statement is

for a selection-statement, any of its statements(but not its init-statement)

It clearly says that the statements that appeared in the grammar of a selection-statement are its substatement.

Instead, the definition for substatements of an iteration-statement is

for an iteration-statement, its contained statement (but not an init-statement).

Does it mean, in this example

while(false){
   int a = 0;
}

The declaration statement is also the substatement of the iteration-statement? Because the declaration statement is contained by the iteration-statement? However, it seems not the intent of the standard. So, why the wording for describing the substatements for an iteration-statement and a selection-statement are different?

@tkoeppe
Copy link
Contributor

tkoeppe commented Jan 21, 2021

For a selections statement, you can have things like if <stmt> else <stmt>, and both arms should be considered part of the substatement. I think that may be the reason for the different wording. Does that make sense?

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jan 21, 2021

For a selections statement, you can have things like if <stmt> else <stmt>, and both arms should be considered part of the substatement. I think that may be the reason for the different wording. Does that make sense?

Presumably, that would be the intent of the wording. However, there's no formal definition for the concept "contained statement". Hence, we only consider it in the English meaning here. IMO, that means all statements that be contained in a selection statement. int a = 0; is contained by while(false){ int a = 0; } I think it's vague here. Why not use its statement? That will be clear it refers to these statements which appear in the corresponding grammar. Such as: while ( condition ) statement Rather than refers to the statements contained by the statement.

@jensmaurer jensmaurer self-assigned this Feb 5, 2021
@jensmaurer jensmaurer changed the title The different definitions for the substatements of selection-statement and iteration-statement [stmt.pre] Different definitions for the substatements of selection-statement and iteration-statement Feb 5, 2021
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

Successfully merging a pull request may close this issue.

3 participants