This is the mail archive of the gcc@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: no warning on mixing unsigned and signed



>> I been alerted to a bug in gcc-3.0.4 and 2.96(yeah, I know its a
>> release from RH, but I don't have a 2.95.3 version handy), the
>> following code when built using '-O -Wall' doesn't warn that the
>> comparison can not be false, and converts 'foo' into an empty function
>> since (a-b) can not be negative: 
>> 
>> extern void bar(void);
>> void foo(int a, unsigned int b)
>> {
>>   if ((a - b) < 0)
>>     bar();
>> }
>
>Please file a PR, otherwise your testcase will be lost I fear.
>
>http://gcc.gnu.org/bugs.html

I looked through the code, and found that if I added '-W' to the
command line, the warning:

/tmp/zz.c: In function `x':
/tmp/zz.c:4: warning: comparison of unsigned expression < 0 is always false

is generated.  And since it is documented that way as well, I'm not
going to file a PR(unless someone thinks that -Wall should include
this warning). 

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


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