Re: Booleans, what a wonderful type!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 19, 2007 at 02:38:23AM +0200, ricknu-0@xxxxxxxxxxxxxx wrote:
> > Er...  Of _course_ booleans are values.  And yes, you can say true + false.
> > Guaranteed to evaluate to int, value of expression being 1.  It's perfectly
> > correct C99.  Same as true + true is guaranteed to be 2 (int, again);
> > assigning
> > that to _Bool variable is guaranteed to give 1, aka true (see the rules
> > for conversion to _Bool).
> Can you really say it really is a value? With C definition: ex an positiv
> integer value => 'true' => value not zero, if converted from integer to boolean
> and back. A value would return a specific value on the secound step, right?

Yes.  RTFStandard, please.
 
> > Now, sparse handling of _Bool sucks in quite a few places (e.g. conversion
> > to it is not reduction modulo 2, it's comparison with 0), but I wonder if
> > that's what you have in mind...
> My main goal is to make it able to find possible places where an integer is used
> as an boolean.

I'm afraid that you are confused; what exactly do you mean by "boolean"?
Note that type of 1 == 1 is *not* _Bool; it's defined as int.  You can
convert it to _Bool, but that's it.

Please, read through the relevant sections of standard, starting with
6.3.1.2 and 6.3.1.1[2].  See also 6.5.3.4[5], 6.5.8, 6.5.9, 6.5.13 and
6.5.14 for operations resulting in int 0 or 1.  See 7.16 for stdbool
stuff.
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux