Questions tagged «fall-through»


1
为什么即使我使用[[fallthrough]],GCC也会警告我有关失败的消息?
在下面的代码中,我使用[[fallthrough]]C ++ 1z的standard属性来说明需要进行彻底检查: #include <iostream> int main() { switch (0) { case 0: std::cout << "a\n"; [[fallthrough]] case 1: std::cout << "b\n"; break; } } 使用GCC 7.1,代码可以正确编译。但是,编译器仍然警告我一个失败之处: warning: this statement may fall through [-Wimplicit-fallthrough=] std::cout << "a\n"; ~~~~~~~~~~^~~~~~~~ 为什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.