https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79301
Bug ID: 79301 Summary: With -Werror=pedantic outside C++17 mode, __has_cpp_attribute(fallthrough) is nonzero but [[fallthrough]] fails Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: andersk at mit dot edu Target Milestone: --- One would expect code like this to silence the new -Wimplicit-fallthrough warning that’s been added to -Wextra: switch (x) { case 0: printf("zero\n"); #if __has_cpp_attribute(fallthrough) [[fallthrough]]; #elif __has_cpp_attribute(gnu::fallthrough) [[gnu::falthrough]]; #endif case 1: printf("zero or one\n"); } However, this fails to compile with -Werror=pedantic in C++14 mode or earlier: “error: ‘fallthrough’ is a C++17 feature; use ‘gnu::fallthrough’ [-Werror=pedantic]”. __has_cpp_attribute(fallthrough) should evaluate to 0 if [[fallthrough]] is not going to work.