Remove switch case fallthrough

Paulo Pinto pjmlp at progtools.org
Fri May 14 08:24:46 UTC 2021


On Friday, 14 May 2021 at 07:00:50 UTC, Mike Parker wrote:
> On Friday, 14 May 2021 at 06:56:55 UTC, Mike Parker wrote:
>
>>
>> But C supports implicit fallthrough, so by deprecating it, we 
>> did make an exception. Ans it's a good exception to make.
>
> Here's what the C++ Core Guidelines say:
>
> "Always end a non-empty case with a break. Accidentally leaving 
> out a break is a fairly common bug. A deliberate fallthrough 
> can be a maintenance hazard and should be rare and explicit."
>
> This is the same reason it's deprecated in D.
>
>
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es78-dont-rely-on-implicit-fallthrough-in-switch-statements

Additionally, since C++17, there is the fallthrough attribute to 
be explicit that the C behaviour is actually intended.

https://en.cppreference.com/w/cpp/language/attributes/fallthrough


More information about the Digitalmars-d mailing list