From 35da095d7e0614235cb0e241685c5e1a240dc882 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 24 Feb 2021 20:07:38 +0100 Subject: [PATCH] libgcc: Avoid signed negation overflow in __powi?f2 [PR99236] When these functions are called with integer minimum, there is UB on the libgcc side. Fixed in the obvious way, the code in the end wants ABSU_EXPR behavior. 2021-02-24 Jakub Jelinek PR libgcc/99236 * libgcc2.c (__powisf2, __powidf2, __powitf2, __powixf2): Perform negation of m in unsigned type. --- libgcc/libgcc2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index 960f594..17de0a7 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -1834,7 +1834,7 @@ __fixunssfSI (SFtype a) TYPE NAME (TYPE x, int m) { - unsigned int n = m < 0 ? -m : m; + unsigned int n = m < 0 ? -(unsigned int) m : (unsigned int) m; TYPE y = n % 2 ? x : 1; while (n >>= 1) { -- 2.7.4