G
Guest
Take this code:
1: int main()
2: {
3: unsigned short x[5] = { 1, 2, 3, 4, 5 };
4: unsigned short sum = 0;
5:
6: for (int i = 0; i < 5; ++i) {
7: sum += x;
8: }
9: }
CL version 13.10.3077 gives the following warning:
err.cpp(7) : warning C4244: '+=' : conversion from 'int' to 'unsigned
short', possible loss of data
Is this correct? Which possible loss of data the compiler is seeing here?
1: int main()
2: {
3: unsigned short x[5] = { 1, 2, 3, 4, 5 };
4: unsigned short sum = 0;
5:
6: for (int i = 0; i < 5; ++i) {
7: sum += x;
8: }
9: }
CL version 13.10.3077 gives the following warning:
err.cpp(7) : warning C4244: '+=' : conversion from 'int' to 'unsigned
short', possible loss of data
Is this correct? Which possible loss of data the compiler is seeing here?