Re: Comparison of promoted ~unsigned
Re: Comparison of promoted ~unsigned
- Subject: Re: Comparison of promoted ~unsigned
- From: Chris Suter <email@hidden>
- Date: Wed, 7 Oct 2009 10:36:18 +1100
On Wed, Oct 7, 2009 at 1:52 AM, Jonny Taylor <email@hidden> wrote:
> 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?
What compiler and version are you using? I don't see this extra
warning on any of the compilers available to me.
-- Chris
_______________________________________________
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