• 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: More 'bool' weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More 'bool' weirdness


  • Subject: Re: More 'bool' weirdness
  • From: Jeffrey Walton <email@hidden>
  • Date: Sat, 15 Jun 2013 16:15:03 -0400

On Sat, Jun 15, 2013 at 3:20 PM, Jens Alfke <email@hidden> wrote:
>
> On Jun 14, 2013, at 6:32 PM, Jeffrey Walton <email@hidden> wrote:
>
> -Wconversion should do the trick.
>
>
> Nope; I checked my project settings and I’ve already got that turned on (as
> “Suspicious Implicit Conversion” in the build settings UI.)
>
> I’ve also got “Implicit Boolean Conversions” (-Wbool-conversion) enabled,
> which certainly sounds like it should detect this, but it doesn’t.
>
> I’ve been using bool instead of BOOL lately, but this C ‘feature’ seems like
> a significant drawback to it, so I’d love to find out if there’s a warning
> that actually detects this misuse.
I was wrong. It appears the warning is not available with GCC and
Clang. I was not able to tease out a warning on both Apple and Linux.
Even with -Wall -Wextra and -Wconversion.

It's probably because the conversion is well defined by the standard:

4.12 Boolean conversions [conv.bool]
1  A prvalue of arithmetic, unscoped enumeration, pointer, or pointer
to member type can be converted to a prvalue of type bool. A zero
value, null pointer value, or null member pointer value is converted
to false; any other value is converted to true. A prvalue of type
std::nullptr_t can be converted to a prvalue of type bool; the
resulting value is false.

Related, Microsoft Visual Studio will warn with /W3 and higher
(http://msdn.microsoft.com/en-us/library/b6801kcy.aspx). Perhaps
that's where I remember seeing the warning.

Jeff

 _______________________________________________
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: More 'bool' weirdness
      • From: Jens Alfke <email@hidden>
References: 
 >More 'bool' weirdness (From: Jens Alfke <email@hidden>)
 >Re: More 'bool' weirdness (From: Jeffrey Walton <email@hidden>)
 >Re: More 'bool' weirdness (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: More 'bool' weirdness
  • Next by Date: Re: More 'bool' weirdness
  • Previous by thread: Re: More 'bool' weirdness
  • Next by thread: Re: More 'bool' weirdness
  • Index(es):
    • Date
    • Thread