I don't know whether it is a bug or not.
Consider the following example:
short int sh1 = 1;
short int sh2 = 2;
printf("Size of short: %d\n", sizeof(short));
printf("Size of int: %d\n", sizeof(int));
printf("Size of expr: %d\n", sizeof(sh1+sh2));
Output:
Size of short: 2
Size of int: 4
Size of expr: 4
GCC is converting short to int while doing any arithmatic operation. Can anyone
explain why it is happening and where exactly(function) does this conversion
happen?
--
Summary: Base type of expressions involving short operands is
shown as int
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: santhosh dot selvaraj at wipro dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25155