https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66322

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> Well, using switch on bool is always weird, one really should use if for
> that.
> If you want fallthrough, then just use if (cond) { first } second, if without
> fallthrough, then if (cond) { first } else { second }.

Indeed. I wrote:

https://gcc.gnu.org/wiki/VerboseDiagnostics#warning:_switch_condition_has_boolean_value_.5B-Wswitch-bool.5D

for future reference. I think there will be always "valid" cases that GCC
cannot avoid warning, so perhaps it is useful to explain the reasoning behind
it and what is the best way to work-around it. (It seems the cast is after all
not the best way, converting it to if-else seems better).

Reply via email to