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

            Bug ID: 87068
           Summary: No diagnostic on an ill-formed [[fallthrough]]
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luk32 at o2 dot pl
  Target Milestone: ---

gcc cleanly compiles an ill-formed [[fallthrough]] example from the standard,
producing no diagnostic. I believe it's a bug.

Problematic code:

// http://eel.is/c++draft/dcl.attr.fallthrough
void f(int n) {
  void g(), h(), i();
  switch (n) {
  case 1:
  case 2:
    g();
    [[fallthrough]];
  case 3:                       // warning on fallthrough discouraged
    h();
  case 4:                       // implementation may warn on fallthrough
    i();
    [[fallthrough]];            // ill-formed
  }
}

Live example https://godbolt.org/z/fftSM-
Credit:
https://stackoverflow.com/questions/51983560/should-there-be-a-diagnostic-from-from-gcc-for-this-ill-formed-c-code

Reply via email to