In the following code snippet, I use the standard [[fallthrough]] attribute from C ++ 1z to document what passing is required:
#include <iostream> int main() { switch (0) { case 0: std::cout << "a\n"; [[fallthrough]] case 1: std::cout << "b\n"; break; } }
With GCC 7.1, the code compiles without errors. However, the compiler still warns me of the failure:
warning: this statement may fall through [-Wimplicit-fallthrough=] std::cout << "a\n"; ~~~~~~~~~~^~~~~~~~
Why?
c ++ c ++ 1z switch-statement
s3rvac Jul 11 '17 at 6:16 2017-07-11 06:16
source share