[Bug c++/91964] Wrong -Wint-in-bool-context warning for enum constant

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Oct 2 09:12:00 GMT 2019


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jörg Richter from comment #0)
> I think all warnings are wrong because nowhere is a enum constant in a
> boolean context.

The warning is documented as diagnosing "using non-boolean integer constants in
boolean context". C has the value 2 in all cases, no matter what form of cast
you use, which is a "non-boolean" value.

> Enums 'A' and 'B' dont seem to trigger the warning.

A and B have values 0 and 1.

The warning seems to be behaving as intended.


More information about the Gcc-bugs mailing list