From 0082dfb7e592bc5376cad2d6e2b298ff6cca3ee8 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 16 Oct 2025 16:12:11 +0900 Subject: [PATCH] mruby-random: fix unary minus on unsigned type warning replace (-rot) with (32 - rot) to avoid msvc warning c4146. both expressions are equivalent when masked with & 31, but the latter is clearer and doesn't trigger warnings about negating unsigned values. Co-authored-by: Claude --- mrbgems/mruby-random/src/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrbgems/mruby-random/src/random.c b/mrbgems/mruby-random/src/random.c index 573ae1589..f7fe32319 100644 --- a/mrbgems/mruby-random/src/random.c +++ b/mrbgems/mruby-random/src/random.c @@ -82,7 +82,7 @@ rand_uint32(rand_state *rng) uint32_t rot = (uint32_t)(oldstate >> 59u); /* Rotate right by rot bits (handles rot=0 case correctly) */ - return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); + return (xorshifted >> rot) | (xorshifted << ((32 - rot) & 31)); } #ifndef MRB_NO_FLOAT