Re:Fixing a 37-year-old bug by merging a 22-year-old fix
by duaneb on Wednesday October 08, 2014 @05:32PM
(#8429576)
There are no booleans in C, just ints. I think c99 added a 'bool' type, but it's just typedef'd to being an int.
[ Parent
| on HN ]
Re:Fixing a 37-year-old bug by merging a 22-year-old fix
by ambrop7 on Wednesday October 08, 2014 @06:50PM
(#8429872)
That is not correct. In C99, _Bool (and the typedef bool) are special, because when any value is converted to _Bool, the result is 0 or 1 (!!x). Although the standard does not explicitly say that _Bool can only hold anything other than 0 and 1 (only that it is capable of representing these values), this seems to be the case, effectively.
Re:Fixing a 37-year-old bug by merging a 22-year-old fix
by adsr on Wednesday October 08, 2014 @06:50PM
(#8429874)
It's a bit more, the bool type can only hold two values, 0 and 1. (6.3.1.2 Boolean type #1) "When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1."