From: Tobias Burnus Date: Wed, 3 Mar 2021 07:05:45 +0000 (+0100) Subject: libgfortran: Fix negation for largest integer [PR81986] X-Git-Tag: upstream/12.2.0~9484 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=006693a59f7cd1310aed53a2816020bedf1fb742;p=platform%2Fupstream%2Fgcc.git libgfortran: Fix negation for largest integer [PR81986] libgfortran/ChangeLog: 2021-03-01 Vittorio Zecca Tobias Burnus PR libfortran/81986 * runtime/string.c (gfc_itoa): Cast to unsigned before negating. --- diff --git a/libgfortran/runtime/string.c b/libgfortran/runtime/string.c index 37c4da0..536a9cd 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;