Talk:cpp/language/switch
From cppreference.com
Regarding the "default:" label, the C spec says this:
> If expression evaluates to a value that doesn't match any of the case: labels, and the default: label is present, control is transferred to the statement labeled with the default: label.
> If expression evaluates to a value that doesn't match any of the case: labels, and the default: label is not present, none of the switch body is executed.
However the later statement is missing from the C++ Explanation section.
Is it missing from the Standard, too, leaving this unspecified, or is this an error on this page ? Laszlo (talk) 08:47, 22 November 2021 (PST)
- The standard doesn't leave this unspecified: "If no case matches and if there is no default then none of the statements in the switch is executed" [1] --Ybab321 (talk) 10:03, 22 November 2021 (PST)
- ✔ Good catch. The missed statement was finally appended.) --Space Mission (talk) 20:17, 23 November 2021 (PST)