Author: pfg
Date: Mon Jan  7 17:35:09 2019
New Revision: 342851
URL: https://svnweb.freebsd.org/changeset/base/342851

Log:
  pow(3): Workaround possible signed shift Undefined Behavior.
  
  j is int32_t and thus j<<31 is undefined if j==1.
  
  Hinted by:    muusl-lib (git 688d3da0f1730daddbc954bbc2d27cc96ceee04c)
  Discussed with:       freebsd-numerics (kargl)

Modified:
  head/lib/msun/src/e_pow.c

Modified: head/lib/msun/src/e_pow.c
==============================================================================
--- head/lib/msun/src/e_pow.c   Mon Jan  7 16:36:45 2019        (r342850)
+++ head/lib/msun/src/e_pow.c   Mon Jan  7 17:35:09 2019        (r342851)
@@ -133,7 +133,7 @@ __ieee754_pow(double x, double y)
                k = (iy>>20)-0x3ff;        /* exponent */
                if(k>20) {
                    j = ly>>(52-k);
-                   if((j<<(52-k))==ly) yisint = 2-(j&1);
+                   if(((u_int32_t)j<<(52-k))==ly) yisint = 2-(j&1);
                } else if(ly==0) {
                    j = iy>>(20-k);
                    if((j<<(20-k))==iy) yisint = 2-(j&1);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to