• 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: Incorrect warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incorrect warning


  • Subject: Re: Incorrect warning
  • From: Chris Espinosa <email@hidden>
  • Date: Mon, 15 Nov 2004 10:31:25 -0800

On Nov 15, 2004, at 10:11 AM, Steve Mills wrote:

Why is this a warning?

DescType        x;

if(x != enumAddItemName && x != enumAddItemData) <--this line

generates this warning:
warning: comparison is always true due to limited range of data type


And this:

if(GetAEClass() == cUserScrollList || GetAEClass() == cUserTextScroller) <--this line

DescType GetAEClass(void) const { return one of many constants; }

generates this warning:
warning: comparison is always false due to limited range of data type


All constants used in our AppleEvent code are defined in one large enum, e.g.:


enum {
    enumAddItemName = 'ÜDDN',
    enumAddItemData = 'ÜDDD',
    cUserTextScroller = 'ÜTSc',
    cUserScrollList    = 'ÜScL',
    etc...
};

In those 4, the first byte is umlaut-U, in case it doesn't make it through mail. Those 2 warnings are obviously wrong, which makes me wonder if Xcode/gcc will compile them out when optimizations are turned on.

Because a) DescType is defined as unsigned; b) your enum is implicitly signed; and c) your enumerators are all negative. They can never be equal to an unsigned (i.e. always positive) value.


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


References: 
 >Incorrect warning (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: can't locate file -lcrt1.o
  • Next by Date: Re: Xcode src tree file behavior and Java parsing
  • Previous by thread: Incorrect warning
  • Next by thread: Re: Incorrect warning
  • Index(es):
    • Date
    • Thread