mirror of git://sourceware.org/git/glibc.git
math: Fix UB on llroundl
Building with --enable-ubasn triggers: UBSAN: Undefined behaviour in ../sysdeps/ieee754/ldbl-96/s_llroundl.c:70:25 left shift of 4294967296 by 31 cannot be represented in type 'long long int' The right shift is undefined if value overflow, but code is assuming an arithmetic shift.
This commit is contained in:
parent
b7c497474b
commit
51a2a92502
|
|
@ -67,7 +67,8 @@ __llroundl (long double x)
|
|||
|
||||
if (j0 > 31)
|
||||
{
|
||||
result = (result << (j0 - 31)) | (j >> (63 - j0));
|
||||
result = ((unsigned long long int)result << (j0 - 31))
|
||||
| (j >> (63 - j0));
|
||||
#ifdef FE_INVALID
|
||||
if (sign == 1 && result == LLONG_MIN)
|
||||
/* Rounding brought the value out of range. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue