cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[stmt.switch] Replace “within a switch statement” with “associated with a switch statement” #566

Open xmcgcg opened 3 days ago

xmcgcg commented 3 days ago

Full name of submitter: Geng Cheng

Reference: [stmt.switch]

Issue description:

[stmt.switch] p2 says:

No two of the case constants in the same switch shall have the same value after conversion.

[stmt.switch] p3 says:

There shall be at most one label of the form default : within a switch statement.

Consider the following example:

switch (1)
{
    case 1:  // the first case 1 label within the outer switch
    default: // the first default label within the outer switch
        switch (1)
        {
            case 1:  // Error: the second case 1 label within the outer switch
            default: // Error: the second default label within the outer switch
        }
}

case and default labels associated with the inner switch statement are also within the outer switch statement.

Suggested resolution: Use “associated with” throughout [stmt.switch], suggested wording changes: