Given the following code:
bool doGoodThing;
switch (some_variable)
{
case 1:
case 2:
doGoodThing = true;
default:
doGoodThing = false;
}
Latest gcc
version are smart enough to detect when variables are being assigned to but still not used, etcetera. Is there any compiler or flag that could trigger a warning saying that the whole switch does not make any sense for a code like this?
UPDATE: The question is not about doGoodThing
variable. It is about a silly switch
statement that doesn't make much sense.
UPDATE 2: Passing "dupe" voters, before you mark it as a duplicate - read a question one more time. This is not about a warning for a missing "break" statement after "case". This is about dead code, logical errors, static semantics analysis of the code by compiler. I do not need a warning if "break" is not there.