This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH RFC: Fix enum comparisons


"Joseph S. Myers" <joseph@codesourcery.com> writes:

> 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.

That is correct.  That is also the behaviour of g++.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]