Re: Any way to get a warning if a non-boolean type is used in an if expression?
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