• 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: Any way to get a warning if a non-boolean type is used in an if expression?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any way to get a warning if a non-boolean type is used in an if expression?


  • Subject: Re: Any way to get a warning if a non-boolean type is used in an if expression?
  • From: Sean McBride <email@hidden>
  • Date: Thu, 17 Oct 2013 11:15:24 -0400
  • Organization: Rogue Research Inc.

On Wed, 16 Oct 2013 17:39:34 -0700, Rick Mann said:

>Java disallows expressions that don't evaluate to boolean type inside an
>if () expression. I just found a bug where an if() expression wasn't
>getting the -boolValue of an NSNumber*, and so it was always evaluating
>to true.
>
>Is there any way to get an error or warning if the result of an
>expression isn't one of the C/C++/Objective-C/C++ boolean types (BOOL, bool)?

I don't believe there is.  But you can check for yourself by turning on -Weverything and seeing if any warning is emitted for your test case.  I doubt it, because there would be so many false positives (where people are deliberately checking that a pointer is non-nil).

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada



 _______________________________________________
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


  • Prev by Date: Re: iOS7 Control Center Documentation ?
  • Next by Date: Re: iOS7 Control Center Documentation ?
  • Previous by thread: Re: iOS7 Control Center Documentation ?
  • Next by thread: Re: Any way to get a warning if a non-boolean type is used in an if expression?
  • Index(es):
    • Date
    • Thread