Why is GCC warning me about a fallthrough even when I use [[fallthrough]]?
Solution 1:
You are missing a semicolon after the attribute:
case 0:
std::cout << "a\n";
[[fallthrough]];
// ^
case 1:
The [[fallthrough]]
attribute is to be applied to an empty statement (see P0188R1). The current Clang trunk gives a helpful error in this case:
error: fallthrough attribute is only allowed on empty statements
[[fallthrough]]
^
note: did you forget ';'?
[[fallthrough]]
^
;
Update: Cody Gray reported this issue to the GCC team.