lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Strange "always true" conditional in tcp_in.c


From: Mike Kleshov
Subject: Re: [lwip-users] Strange "always true" conditional in tcp_in.c
Date: Mon, 1 Mar 2010 12:52:52 +0300

On 1 March 2010 12:31, Kieran Mansley <address@hidden> wrote:
> I would be interested in a reference to the C standard that explains why
> this would be cast to an int.

Here is the relevant portion of C99:
-quote-
If both operands have the same type, then no further conversion is needed.
Otherwise, if both operands have signed integer types or both have unsigned
integer types, the operand with the type of lesser integer conversion rank is
converted to the type of the operand with greater rank.
Otherwise, if the operand that has unsigned integer type has rank greater or
equal to the rank of the type of the other operand, then the operand with
signed integer type is converted to the type of the operand with unsigned
integer type.
Otherwise, if the type of the operand with signed integer type can represent
all of the values of the type of the operand with unsigned integer type, then
the operand with unsigned integer type is converted to the type of the
operand with signed integer type.
Otherwise, both operands are converted to the unsigned in
corresponding to the type of the operand with signed integer type.
-end of quote-
So yes, operands will be converted to int since 1 is an int.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]