Is your switch-statement missing "case 0:"?While it is missing a case 0: it is also missing a default: as well for catching things like this. Default cases are good for when you are unsure if you've got all the cases and/or catching errors as well.
Check the values your are using to calculate your rotation.
While it is missing a case 0: it is also missing a default: as well for catching things like this. Default cases are good for when you are unsure if you've got all the cases and/or catching errors as well.When you're unsure if you've got all the cases, you have a serious problem, because you don't understand your program's logic.
By adding a default: case in such a case and performing regular logic (or nothing) inside it, you prevent possible compiler warnings and hide logic errors. The only sane thing to do in such a "catch-all" default: label is an assert(false);, because this branch of execution shall never be reached in a well-written program.My personal preference tends to be to use (with gcc/clang) the "-Wswitch" flag which causes a warning if a switch does not handle all possible cases and then also use "-Werror" to turn all compiler warnings into errors. Then I know when I fucked up and forgot to handle a case and can deal with it (usually by explicitly handling it, but possibly by adding a default) before I even try to run my code.
Note that I'm not talking against default: when its intention is clear, but against the practice of adding it "if you're unsure".
My personal preference tends to be to use (with gcc/clang) the "-Wswitch" flag which causes a warning if a switch does not handle all possible cases and then also use "-Werror" to turn all compiler warnings into errors.The problem with that approach is that it forces you to write default: so often that it almost becomes a defensive automatism. At least that was my impression...