From 44168020e264b3e6288d42dcb57c24c1e07077b8 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Thu, 23 Jan 2020 23:57:36 +0100 Subject: [PATCH] Add an explicit cat to uint32_t in inl_erand48() to silence a runtime error from the undefined behaviour sanitizer --- src/random.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/random.h b/src/random.h index 8618f77ff..b54da03ab 100644 --- a/src/random.h +++ b/src/random.h @@ -107,7 +107,7 @@ INLINE static double inl_erand48(uint16_t xsubi[3]) { temp.ieee.negative = 0; temp.ieee.exponent = IEEE754_DOUBLE_BIAS; temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12); - temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4); + temp.ieee.mantissa1 = (((uint32_t)xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4); /* Please note the lower 4 bits of mantissa1 are always 0. */ return temp.d - 1.0; -- GitLab