https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127722

--- Comment #2 from Keith Thompson <Keith.S.Thompson at gmail dot com> ---
This came out of a recent discussion on comp.lang.c.

After a recent post by Kaz Kylheku, I realize that the example may
or may not strictly speaking be a "fallthrough".

Given:

switch (foo) {
    case 0:
    case 1:
        break;
}

when foo==0, I had thought of it as branching to the "case 0:"
and then falling through the "case 1:".  In fact, according to
the grammar, "case 0: case 1: break;" is a single labeled-statement.

Breaking it down according to the grammar:

    break;                   is a jump-statement
    case 1: break;           is a labeled-statement
    case 0: case 1: break;   is a labeled statement

But control jumps to "the statement or declaration following the
matched case label", so one could argue that when foo==0, control
jumps to the the "case 0: case 1: break;" statement.

C23 makes things a bit more complicated by treating labels as
"block-items" at the same syntactic level as statements within
a block.

C23 also adds the "fallthrough" attribute, so the idea of fallthrough
is now part of the language (see N3220 6.7.13.6).

I still think it's worth mentioning that jumping to one of a series
of consecutive case labels should not be considered a "fallthrough".
I'm just having more trouble thinking about how distill all this
into simple wording in the documentation that won't scare users.

Reply via email to