https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91024
Bug ID: 91024 Summary: -Wimplicit-fallthrough is confused by likely/unlikely attributes Product: gcc Version: 9.1.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- int f(char c) { int result = 0; switch (c) { case 'O': case 'K': return result; [[unlikely]] case 'X': case 'x': return result; default: break; } return result; } attr.cc: In function 'int f(char)': attr.cc:10:18: warning: this statement may fall through [-Wimplicit-fallthrough=] 10 | [[unlikely]] case 'X': | ^~~~ attr.cc:11:5: note: here 11 | case 'x': | ^~~~ Without the attribute there, there's no warning about fallthrough (because the case is empty). The attribute causes it to warn. At a guess, the code that decides whether a case is empty should ignore attributes in the tree.