[Bug libfortran/95177] error: array subscript has type char

roland.illig at gmx dot de gcc-bugzilla@gcc.gnu.org
Thu Dec 16 19:57:23 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177

--- Comment #17 from Roland Illig <roland.illig at gmx dot de> ---
(In reply to Francois-Xavier Coudert from comment #16)
> I feel like the "array subscript has type char" error is really a red
> herring in this case.

I agree, especially for C programmers who are not aware that the functions from
<ctype.h> are most often implemented as macros. GCC should try to bridge this
gap and provide a more accurate, more helpful diagnostic in cases like these.

> The four functions currently used in libgfortran are: isalnum, isdigit,
> tolower, toupper. Patch incoming.

I already attached a patch 18 months ago, using the standard pattern that
everyone else uses to properly fix the type mismatch. I don't think much has
changed in the meantime, so my patch should still apply.

Here are some ideas for implementing this check in a more direct way:

https://github.com/NetBSD/src/blob/trunk/usr.bin/xlint/lint1/ckctype.c
https://github.com/NetBSD/src/blob/trunk/tests/usr.bin/xlint/lint1/msg_341.c
https://github.com/NetBSD/src/blob/trunk/tests/usr.bin/xlint/lint1/msg_342.c


More information about the Gcc-bugs mailing list