We compile our code under warning level 4 and want to have the C4244 warning
enabled as it sometimes catch problems in the code.
However, consider the following code:
unsigned char a, b;
a += b; // Generates warning
a = a + b; // Does not generate warning
The problem is that C++ will expand the type of the + expression to int and
then implicitly convert the int to unsigned char, which should generate a
warning.
We dunno if the compiler folks at Microsoft thought "hey thats silly to warn
here" and disabled the warning for the regular assigment but forgot to
disable it for the += assignment or if they made an error not reporting the
implicit conversion of the type in the regular assignment with the C4244
warning.
We would very much like VC would not warn for either assignment operators
when types are implicitly expanded and then implicitly reduced as this is
never a warning you care about.
Currently, we have to use the second form to avoid the warning but if the VC
teams decides to warn here also we really need to write:
a = (unsigned char)(a + b);
And this kinda sucks. (Although it is really C++ that sucks here)
Regards
Ulf Johansen