gcc 4.3.0, -Wconversion: assignment-by operators for shorter types
Manuel López-Ibáñez
lopezibanez@gmail.com
Wed Jul 30 09:38:00 GMT 2008
2008/5/27 Andrew Pinski <pinskia@gmail.com>:
> On Tue, May 27, 2008 at 11:56 AM, Andriy Gapon <avg@icyb.net.ua> wrote:
>> Thank you for the explanation! I didn't realize the difference.
>>
>> OTOH, do you think that those arithmetic warnings are practical (as opposed
>> to being correct)?
>
> I think so as the short int case has a defined overflow of the signed
> short type that is SHRT_MAX + 1 is defined while INT_MAX + 1 is not.
Andrew, I don't understand what you mean by "SHRT_MAX + 1 is defined
while INT_MAX + 1 is not".
Is there actually any difference in the following cases given short
short_x = SHRT_MAX ?
short_x = short_x + 1;
short_x += 1;
short_x++;
++short_x;
What about unsigned short ushort_x = USHRT_MAX ?
ushort_x = ushort_x + 1;
ushort_x += 1;
ushort_x++;
++ushort_x;
Cheers,
Manuel.
More information about the Gcc
mailing list