Bug 91432 - gcc -Wimplicit-fallthrough does not warn when fallthrough to break;
Summary: gcc -Wimplicit-fallthrough does not warn when fallthrough to break;
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-13 07:40 UTC by Joe Perches
Modified: 2019-08-13 21:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Perches 2019-08-13 07:40:57 UTC
This code does not emit a fallthrough warning:

int foo(int i)
{
  switch (i) {
  case 1:
    i = 0;
  default:
    break;
  }
  return i;
}

Basically any case block that falls through to another
block of just a break statement does not get a warning.

Is this a defect or what was the logic behind this decision?
Comment 1 Marc Glisse 2019-08-13 08:16:07 UTC
The warning basically says "you may have forgotten 'break;'". If it falls through to break anyway, what difference does it make if I add a redundant break?