summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-03-03 08:05:45 +0100
committerTobias Burnus <tobias@codesourcery.com>2021-03-03 08:07:16 +0100
commit006693a59f7cd1310aed53a2816020bedf1fb742 (patch)
tree95696ff7fb8d784e3d29ae93b796bd1f499eac4e /libgfortran
parentf8e7f3f3f33e22721a28772cc3f9b616e48cd1c9 (diff)
libgfortran: Fix negation for largest integer [PR81986]
libgfortran/ChangeLog: 2021-03-01 Vittorio Zecca <zeccav@gmail.com> Tobias Burnus <tobias@codesourcery.com> PR libfortran/81986 * runtime/string.c (gfc_itoa): Cast to unsigned before negating.
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/runtime/string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libgfortran/runtime/string.c b/libgfortran/runtime/string.c
index 37c4da0a98a..536a9cd3f2b 100644
--- a/libgfortran/runtime/string.c
+++ b/libgfortran/runtime/string.c
@@ -196,7 +196,7 @@ gfc_itoa (GFC_INTEGER_LARGEST n, char *buffer, size_t len)
if (n < 0)
{
negative = 1;
- t = -n; /*must use unsigned to protect from overflow*/
+ t = -(GFC_UINTEGER_LARGEST) n; /* Must use unsigned to protect from overflow. */
}
p = buffer + GFC_ITOA_BUF_SIZE - 1;