[Bug c++/126924] New: Wimplicit-fallthrough not issued if next case only contains a break

headch at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126924

            Bug ID: 126924
           Summary: Wimplicit-fallthrough not issued if next case only
                    contains a break
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: headch at gmail dot com
  Target Milestone: ---

This code does not generate a Wimplicit-fallthrough warning:

void g();

void f(int x) {
    switch(x) {
        case 1:
          g();
        case 2:
          //g();
          break;
    }
}

It does if you uncomment the commented-out line. It seems to me that it should
generate a Wimplicit-fallthrough warning either way—my understanding is that
the intention is to not generate the warning if the case you are falling *from*
is empty (so you can group case labels together that all have the same
handling), not if the case you are falling *into* is empty (which seems like
nothing special, and ought to be warned about).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.