https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78155
Bug ID: 78155 Summary: missing warning on invalid isalpha et al. Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Isalpha and other character classification functions/macros defined in the <ctype.h> header require their argument to be in range of unsigned char or EOF and have undefined behavior otherwise. On some implementations (such as Glibc), calling them with an argument outside that range crashes the program (see below). To help detect this common error GCC should issue a warning when the argument is known to be invalid (as in the test case below) or when its value or range is unknown, when it its type is char that is subject to sign extension. $ cat b.c && /build/gcc-git/gcc/xgcc -B/build/gcc-git/gcc -Wall -Wextra -Wpedantic -fdump-tree-optimized=/dev/stdout b.c && ./a.out int main (void) { __builtin_printf ("%i\n", __builtin_isalpha (999999)); } ;; Function main (main, funcdef_no=2, decl_uid=1965, cgraph_uid=2, symbol_order=2) main () { int D.1968; int _1; int _4; <bb 2>: _1 = __builtin_isalpha (999999); __builtin_printf ("%i\n", _1); _4 = 0; <L0>: return _4; } Segmentation fault (core dumped)