diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2025-03-18 21:17:03 +0000 |
---|---|---|
committer | James K. Lowden <jklowden@cobolworx.com> | 2025-03-26 16:49:11 -0400 |
commit | e2c93a07d739034e5375e69da38091efc87d56e9 (patch) | |
tree | 91786d87191cf7c74ffdde15644aed5df665a99d /gcc | |
parent | b1a58dcb238c5a48e24f226c89287595ef7a9225 (diff) | |
download | gcc-e2c93a07d739034e5375e69da38091efc87d56e9.zip gcc-e2c93a07d739034e5375e69da38091efc87d56e9.tar.gz gcc-e2c93a07d739034e5375e69da38091efc87d56e9.tar.bz2 |
libgcobol: Fix uses of tolower and toupper with std::transform
As explained in the libstdc++ manual[1] and elsewhere[2], using tolower
and toupper in std::transform directly is wrong. If char is signed then
non-ASCII characters with negative values lead to undefined behaviour.
Also, tolower and toupper are overloaded names in C++ so expecting them
to resolve to a unique function pointer is unreliable. Finally, the
<cctype> header was included, not <ctype.h>, so they should have been
qualified as std::tolower and std::toupper.
[1] https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.simple
[2] https://en.cppreference.com/w/cpp/string/byte/tolower
libgcobol/ChangeLog:
* intrinsic.cc (is_zulu_format): Qualify toupper and cast
argument to unsigned char.
(fill_cobol_tm): Likewise.
(iscasematch): Likewise for to lower.
(numval): Qualify calls to tolower.
(__gg__lower_case): Use lambda expression for
tolower call.
(__gg__upper_case): Likewise for toupper call.
* libgcobol.cc (mangler_core): Cast tolower argument to unsigned
char.
* valconv.cc (__gg__string_to_numeric_edited): Cast to upper
arguments to unsigned char.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions