]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB on dbl-64 rint
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 6 May 2025 13:38:31 +0000 (13:38 +0000)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 8 May 2025 12:25:49 +0000 (09:25 -0300)
UBSAN: Undefined behaviour in ../sysdeps/ieee754/dbl-64/s_rint.c:53:4 left shift of 1 by 63 cannot be represented in type 'long long int'

sysdeps/ieee754/dbl-64/s_rint.c

index 8604733ef95481cf82132a1dfcb3011cea29b133..450d886655b4072ff4847e81d00e17ff142384c0 100644 (file)
@@ -37,7 +37,8 @@ __rint (double x)
                4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
                -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
   };
-  int64_t i0, sx;
+  int64_t i0;
+  uint64_t sx;
   int32_t j0;
   EXTRACT_WORDS64 (i0, x);
   sx = (i0 >> 63) & 1;