16

It is amazing what breaks when you don't insert a break in your case.

Comments
  • 4
    It definitely makes for some hard to find bugs. They really "fall through" the cracks
  • 2
    I have never liked the case statement.
  • 3
    C/C++? Enable your compiler warnings. GCC mandates a proper fallthrough comment for intentionally falling through a non-empty case. Also enable -Werror so that code with warnings won't compile.
  • 4
    Its a sign, take a break...
  • 0
    Yup. switch is so much better with implicit breaks and explicit fallthrough.
    And yes, Swift and Kotlin do have this kind of switches.
  • 1
    @Fast-Nop I have clang warnings in my editor. Didn't show up for some reason. Or I didn't notice. There are so many compiler warnings that I have learned to ignore them... We have been discussing how to reduce these in our team.
  • 2
    @Demolishun That sounds pretty bad and should be fixed to "no warnings allowed". Sure, time and cost, but chasing and fixing bugs that the compiler could have warned about is also money. OK, Clang's -Weverything is overdone and actually just generates noise.

    From there on, a tool like CppCheck would be the logical next step into static code analysis.
  • 2
    noBreaks === noBrakes
Add Comment