]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Cast arguments of <ctype.h> functions to unsigned char
authorFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Thu, 16 Dec 2021 17:38:30 +0000 (18:38 +0100)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Sat, 18 Dec 2021 08:21:16 +0000 (09:21 +0100)
commit21423a1dfa079d4cd218f69d2fab9fe65a69fedb
tree08f1191472543839ad785d3bc99b304118528fba
parentf18cbc1ee1f421a0dd79dc389bef9a23dd4a761d
Fortran: Cast arguments of <ctype.h> functions to unsigned char

Functions from <ctype.h> should only be called on values that can be
represented by unsigned char. On targets where char is a signed type,
some of libgfortran calls have undefined behaviour.

The solution is to cast the argument to unsigned char type. I’ve defined
macros in libgfortran.h to do so, to retain legibility of the library
code.

PR libfortran/95177

libgfortran/ChangeLog

* libgfortran.h: include ctype.h, provide safe macros.
* io/format.c: use safe macros.
* io/list_read.c: use safe macros.
* io/read.c: use safe macros.
* io/write.c: use safe macros.
* runtime/environ.c: use safe macros.
libgfortran/io/format.c
libgfortran/io/list_read.c
libgfortran/io/read.c
libgfortran/io/write.c
libgfortran/libgfortran.h
libgfortran/runtime/environ.c