• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Comparison of promoted ~unsigned
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Comparison of promoted ~unsigned
      • From: Jonny Taylor <email@hidden>
References: 
 >Comparison of promoted ~unsigned (From: Jonny Taylor <email@hidden>)

  • Prev by Date: Re: Comparison of promoted ~unsigned
  • Next by Date: Re: How to work on case-sensitive projects?
  • Previous by thread: Re: Comparison of promoted ~unsigned
  • Next by thread: Re: Comparison of promoted ~unsigned
  • Index(es):
    • Date
    • Thread