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 RFA: C++: Avoid inappropriate -Wsign-compare warnings


Paolo Bonzini <paolo.bonzini@gmail.com> writes:

> Ian Lance Taylor wrote:
>> Here is a better patch to address the problem described in some detail
>> in http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01393.html .  In this
>> patch I simply set TREE_NO_WARNING for cases where we are using a
>> builtin operator and we have cast an unsigned enum type to a signed
>> integral type.  Then I test TREE_NO_WARNING before calling
>> warn_sign_compare.
>
> I'm wondering what happens for unsigned enums whose biggest member is
>>= 2^31.  Maybe you have to test TYPE_PRECISION in
> avoid_sign_compare_warnings?

An enum whose biggest member is that large will not be cast to a signed
int, since that would not work.  See type_promotes_to in cp/cvt.c.  So
this patch won't change the behaviour, which is to say that you will get
a warning if an instance of the enum type is compared with a signed int
and not if compared with an unsigned int.

Ian


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