The C standard specifies the following for isdigit() and the other character classification functions: The functions in this subclause return nonzero (true) if and only if the value of the argument c conforms to that in the description of the function. Although Glibc strictly conforms to this requirement, it returns a different non-zero value from the function than from the corresponding macro. I think returning the same value from both would improve the quality of the implementation. In addition, returning 1 from both instead of a seemingly arbitrary non-zero value would prevent bugs like those discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82272. (See WG14 paper N2229 for a proposal to help detect these bugs.) #include <assert.h> #include <ctype.h> #include <stdio.h> int main (void) { int i = isdigit ('1'); int j = (isdigit)('1'); printf ("%i %i\n", i, j); assert (isdigit ('1') == (isdigit)('1')); return 0; } 2048 1 tst-isdigit.c:12: main: Assertion `isdigit ('1') == (isdigit)('1')' failed.
> (See WG14 paper N2229 for a proposal to help detect these bugs.) What does it say?
N2229 just published today: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2229.htm
The same thing can happen with memcmp due to compiler intrinsics. I'm not sure if fixing isdigit specifically is warranted.