Summary: plain char arguments to <ctype.h> functions
Submitted by: None
Submitted on: Sun 01 Mar 2020 01:10:01 PM UTC
Severity: 3 - Normal
Item Group: None
Assigned to: None
Discussion Lock: Any
Component Version: None
Operating System: None
Fixed Release: None
Triage Status: None
Building git head currently fails because of an ancient sin: passing plain
char arguments to functions from <ctype.h>. E.g. this happens on Cygwin with
In file included from src/makeint.h:75,
src/load.c: In function 'load_file':
src/load.c:198:23: error: array subscript has type 'char'
198 | while (isalnum (*fp) || *fp == '_')
cc1: all warnings being treated as errors
The argument to these function/macros is formally an int, holding either a
value from the range of unsigned char, or EOF. Plain char might be signed,
which is unsuitable for this usage.
So everywhere a plain char is passed to isalpha(), isspace() etc., it has to
be cast to (unsigned char) first.
Please note that the above is not the only one in the source that is wrong in
this regard. It's just the only one active in this particular build.