public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Avoid signed shift overflow in pow (bug 21309) [committed]
@ 2017-12-19 18:41 Joseph Myers
  0 siblings, 0 replies; only message in thread
From: Joseph Myers @ 2017-12-19 18:41 UTC (permalink / raw)
  To: libc-alpha

As noted in bug 21309, dbl-64/e_pow.c contains signed int shifts that,
although the shift count is in the range [0, 31], shift bits into and
beyond the sign bit and so are undefined in ISO C.  Although this is
defined in GNU C, this patch from the bug cleans up the code to avoid
those shifts.

Tested for x86_64.  Committed.

2017-12-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	[BZ #21309]
	* sysdeps/ieee754/dbl-64/e_pow.c (checkint): Make m and n
	unsigned.

diff --git a/sysdeps/ieee754/dbl-64/e_pow.c b/sysdeps/ieee754/dbl-64/e_pow.c
index 2eb8dbf..d3cb42d 100644
--- a/sysdeps/ieee754/dbl-64/e_pow.c
+++ b/sysdeps/ieee754/dbl-64/e_pow.c
@@ -452,7 +452,8 @@ checkint (double x)
     int4 i[2];
     double x;
   } u;
-  int k, m, n;
+  int k;
+  unsigned int m, n;
   u.x = x;
   m = u.i[HIGH_HALF] & 0x7fffffff;	/* no sign */
   if (m >= 0x7ff00000)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-19 18:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19 18:41 Avoid signed shift overflow in pow (bug 21309) [committed] Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).