-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider making it an error to implicitly fall through without __fallthrough;
annotation in switch cases
#43308
Comments
@stephentoub This is a C++ feature request. I'm not sure we can do anything about it here. |
Oops. Moved the wrong one. Thanks. |
@Gnbrkm41 would you be interested in enabling the warning to see how many violations it flags? |
Setting coreclr label since this is largely a CoreCLR dev decision. |
I'm not exactly sure how one would enable the analyzer. I heard that for MSVC it's part of the "C++ Core" Style checks (C++ Core Style Rules, ES.78) but presumably we don't want to enable the whole suite of analyzers? |
Hmm, I'll leave this to area owners to consider. |
We can start with |
|
I've started working on it. |
I've just got bitten by implicit fallthroughs in #35713; That makes me wonder how hard it would be to make implicit fallthroughs be warnings / errors, or if it would be worth to do so?
The JIT coding convention states that fallthroughs should be annotated with
__fallthrough;
(https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/clr-jit-coding-conventions.md#124-switch-statements):Given how we encourage people to flag fallthroughs explicitly and C# already makes it an error to omit
break
statements, would it be beneficial enough to make it an error/warning?It appears that C++17 introduces
[[fallthrough]];
attribute, and GNU/Clang recognises this when-Wimplicit-fallthrough
argument is specified and makes these into warnings, but I'm not sure if VS has some flag to allow that, apart from this: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-by-compiler-version?view=vs-2019#warnings-introduced-in-visual-studio-2017-rtm-compiler-version-1910250170The text was updated successfully, but these errors were encountered: