math: Fix UB in ldbl-128 lrintl

$ math/test-float128-llrint

UBSAN: Undefined behaviour in ../sysdeps/ieee754/float128/../ldbl-128/s_llrintl.c:83:31 left shift of 281474976710656 by 15 cannot be represented in type 'long long int'
Aborted

UBSAN: Undefined behaviour in ../sysdeps/ieee754/float128/../ldbl-128/s_lrintl.c:111:30 left shift of 281474976710656 by 15 cannot be represented in type 'long int'
Aborted
This commit is contained in:
Adhemerval Zanella 2025-05-05 09:39:07 -03:00
parent c1540fcdde
commit 712ff06cd6
1 changed files with 2 additions and 2 deletions

View File

@ -81,7 +81,7 @@ __lrintl (_Float128 x)
result = (j0 < 0 ? 0 : i0 >> (48 - j0)); result = (j0 < 0 ? 0 : i0 >> (48 - j0));
} }
else if (j0 >= 112) else if (j0 >= 112)
result = ((long int) i0 << (j0 - 48)) | (i1 << (j0 - 112)); result = (i0 << (j0 - 48)) | (i1 << (j0 - 112));
else else
{ {
#if defined FE_INVALID || defined FE_INEXACT #if defined FE_INVALID || defined FE_INEXACT
@ -108,7 +108,7 @@ __lrintl (_Float128 x)
if (j0 == 48) if (j0 == 48)
result = (long int) i0; result = (long int) i0;
else else
result = ((long int) i0 << (j0 - 48)) | (i1 >> (112 - j0)); result = (i0 << (j0 - 48)) | (i1 >> (112 - j0));
} }
} }
else else