3 ms·
Note that gcc and clang will warn you about fallthrough statements i you use -Wextra and that you have to either have insert a /fallthrough/ comment to make you
by cassepipe 3y ago
Note that gcc and clang will warn you about fallthrough statements i you use -Wextra and that you have to either have insert a /fallthrough/ comment to make your intent clear.
Pity the (wo)man who does not use -Wall -Wextra for (s)he is truly mistaken
- flohofwoe 3y agoClang actually doesn't warn in -Wextra: https://www.godbolt.org/z/99ejvY9Pc https://www.godbolt.org/z/99ejvY9Pc It requires the separate option -Wimplicit-fallthrough: https://www.godbolt.org/z/GP576zG9h https://www.godbolt.org/z/GP576zG9h (which tbh sounds like a bug, because usually Clang tries to emulate GCC behaviour)
- a_e_k 3y agoC++17 now has standardized the [[fallthrough]] attribute: https://en.cppreference.com/w/cpp/language/attributes/fallthrough https://en.cppreference.com/w/cpp/language/attributes/fallth... (For backwards compatibility, it still must fallthrough with or without the attribute; the attribute just signals programmer intention and silences the warning.)