Caius said:Here's a real kicker. Try this little program with the -Wconversion flag on gcc 4.3:
int main()
{
short x = 1;
short y = 2;
x += y;
}
The compiler will complain that you're trying to convert a short int to an int, even though they are both shortS! Apparently operators like += will promote the values to int implicitly. From what I've been told this is supposed to be correct behaviour, but it seems rather odd to me. Not even casting the rvalue will help. I believe the only thing you can do now is to either remove the -Wconversion flag, or the -Werror flag and live with the warning. Really annoying.
Sounds like the += is meant for integers instead of shorts, maybe (at least if you're compiling with C++ ) you could overload the += operator. Not sure how to do it myself, but I am pretty sure it can be done.
Samson said:
It's complaining about returning an int when all the variables inside are shorts. Which I think is ludicrous, and I don't care how "correct" it seems, in practice it's just a colossal waste of time. And yes, even more of a waste of developer time than the const issue was. Because at least the const issue had some glimmer of an argument for correctness. This though, this is stupider than using -pedantic.
You make me laugh sometimes, Samson.