[ccache] Compiler warnings in ccache 3.2.3
joel at rosdahl.net
Mon Aug 17 19:04:14 UTC 2015
> I got a few warnings about assignments of pointers to "bool" values. I
> think these are legitimate gripes, because on platforms where bool is only
> a byte wide, the net effect will be to assign the pointer's low-order byte
> to the bool. There's at least a 1-in-256 chance of a non-null pointer
> erroneously converting to a "false" boolean value (maybe more than that, if
> the pointer is likely to be aligned ...).
Well, as I interpret the C99 standard, bool from stdbool.h (AKA _Bool) is
guaranteed to only contain 1 or 0:
"22.214.171.124 Boolean type
When any scalar value is converted to _Bool, the result is 0 if the value
compares equal to 0; otherwise, the result is 1."
However, ccache's system.h has fallback code on systems that don't have
stdbool.h and then a bool can be typedef-ed to be a signed char, which is
something I didn't think of when writing the code in question. (I guess you
are on such an "antique" non-C99 system?)
I propose the attached patches to fix this.
More information about the ccache