[Bug other/17898] New: Incorrect usage of isdigit, etc.
terra at gnome dot org
gcc-bugzilla@gcc.gnu.org
Fri Oct 8 20:36:00 GMT 2004
Doing a
> find . -name \*.c | xargs -n99 egrep -w
'is(upper|alnum|alpha|lower|print|space|digit)' /dev/null
on the gcc 3.4.0 source shows lots of places where the isdigit and friends
are called on plain, possibly signed, characters. These need to be fixed
to cast the argument to "unsigned char". (Lots of instances already do
that.)
Note: several places have casts to int. That will silence gcc on solaris,
for example, but the code will still be wrong.
These all appear wrong:
./libobjc/gc.c: while (isdigit (*++type))
./gcc/config/frv/frv.c: if (code != 0 && !isalpha (code))
./gcc/ada/adaint.c: || (strlen (name) > 1 && isalpha (name[0]) && name[1]
== ':')
./boehm-gc/os_dep.c: while (isspace(c)) c = stat_buf[buf_offset++];
./boehm-gc/os_dep.c: while (!isspace(c)) c = stat_buf[buf_offset++];
./boehm-gc/os_dep.c: while (isspace(c)) c = stat_buf[buf_offset++];
./boehm-gc/os_dep.c: while (isdigit(c)) {
./boehm-gc/cord/de.c: } else if (c < 0x100 && isdigit(c)){
./boehm-gc/cord/de_win.c: while (isspace(*command_line)) command_line++;
./boehm-gc/cord/de_win.c: while (*command_line != 0 &&
!isspace(*command_line)) command_line++;
./boehm-gc/cord/de_win.c: while (isspace(*command_line)) command_line++;
./boehm-gc/cord/de_win.c: while (*p != 0 && !isspace(*p)) p++;
This is wrong, but being a test case might not need fixing:
./gcc/testsuite/gcc.c-torture/execute/991112-1.c: return isprint (c) ? 1 : 2;
These look like someone got a warning and then did the wrong thing to resolve
it. The cast should be to unsigned char, not int:
./libjava/libltdl/ltdl.c: if (!isspace ((int) *p))
./libjava/libltdl/ltdl.c: while (*end && !isspace((int) *end))
./libjava/libltdl/ltdl.c: if (isspace ((int) *p))
./libjava/libltdl/ltdl.c: while (*end && !isspace ((int) *end))
./libjava/libltdl/ltdl.c: if (isalnum ((int)(base_name[i])))
Wrong as above:
./gcc/ada/adadecode.c:#define ISDIGIT(c) isdigit(c)
and later
while (ISDIGIT ((int) ada_name[(int) len - 1 - n_digits]))
--
Summary: Incorrect usage of isdigit, etc.
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: terra at gnome dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17898
More information about the Gcc-bugs
mailing list