There is a code which needs to be compiled with C++17 as well as with an earlier standards. Compiler: GCC. I've tried to use different techniques for a different standards. Those works fine separately (without if-else: c++17 - with attribute, c++14 - with a comment) , but if I try to use those together, in one if-else, it's failed.
There should no be "break" keyword, this is an expected logic for the case.
case 10:
if (/* some condition */) {
// ... some processing
break;
}
#if __cplusplus >= 201703L
[[fallthrough]];
#else
/* fall through */
#endif
default:
// ... other processing
The build with c++14 fails with an error like no "else" branch there:
error: this statement may fall through [-Werror=implicit-fallthrough=]
any idea why it happens