3 ms·
It seems like the C99 _Bool type implements the same implicit type conversion brain damage. It does: "When any scalar value is converted to _Bool, the result i
by rwg 13y ago
It seems like the C99 _Bool type implements the same implicit type conversion brain damage.
It does: "When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1." (from §6.3.1.2 of the N1256 draft)
Compilers will happily compare/set pointers to 0 since that's the null pointer constant (§6.5.9, §6.3.2.3), so there's no warning:
% cat foo.c
#include <stdio.h>
int main() { _Bool b = "blah"; printf("%d\n", b); return 0; }
% gcc -std=c99 -W -Wall -Wextra -o foo foo.c
% ./foo
1