diff mbox series

[committed] libgcc: Avoid signed negation overflow in __powi?f2 [PR99236]

Message ID 20210224191038.GA4020736@tucnak
State New
Headers show
Series [committed] libgcc: Avoid signed negation overflow in __powi?f2 [PR99236] | expand

Commit Message

Jakub Jelinek Feb. 24, 2021, 7:10 p.m. UTC
Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
as obvious.

2021-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR libgcc/99236
	* libgcc2.c (__powisf2, __powidf2, __powitf2, __powixf2): Perform
	negation of m in unsigned type.



	Jakub
diff mbox series

Patch

--- libgcc/libgcc2.c.jj	2021-01-04 10:25:53.727065175 +0100
+++ libgcc/libgcc2.c	2021-02-24 13:33:38.415470027 +0100
@@ -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)
     {