PATCH RFC: Fix enum comparisons

Joseph S. Myers joseph@codesourcery.com
Thu Sep 4 17:12:00 GMT 2008


On Thu, 4 Sep 2008, Richard Guenther wrote:

> Note that I think -Wenum-compare should _not_ be enabled with -Wall.
> That is, I suppose -Wenum-compare will warn about comparing against
> integer constants as well, which is commonly used in C code that
> defines bitmask members as enums like
> 
> enum C { bit1 = 1, bit2 = 2, bit3 = 4 };
> 
> and then do
> 
> enum C x;
> if (x == bit1 | bit2)

My understanding is that the patch only warns for comparisons involving 
two different enums, not those involving an enum and a non-enum integer.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Fortran mailing list