Comparison of promoted ~unsigned
Comparison of promoted ~unsigned
- Subject: Comparison of promoted ~unsigned
- From: Jonny Taylor <email@hidden>
- Date: Tue, 6 Oct 2009 15:52:38 +0100
I am getting some odd warnings with gcc under xcode, and I'm not sure whether this is the compiler being over-zealous or whether it is trying to tell me about a subtle issue I do not appreciate.
The following code generates two warnings: unsigned short a = 1; if (a < ~a) exit(0); if (a < (unsigned short)(~a)) exit(0);
BOTH "if" tests produce the warning: warning: comparison of promoted ~unsigned with unsigned
It seems to me that the second test is free from any issues. Yes, I have inverted an unsigned short, which has involved an implicit promotion to int, but I have then cast it back to unsigned short. As far as I can see, that code will work exactly as I would expect. Is there a problem I am not seeing, or is the compiler warning incorrect in this case?
Thanks for any advice. Jonny
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden