From 81817dacd6dd6f8204518ad50e0c8b534d6a4366 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 6 Nov 2021 21:09:08 -0400 Subject: [PATCH] sim: sh: fix conversion of PC to an integer On LLP64 targets where sizeof(long) != sizeof(void*), this code fails: sim/sh/interp.c:704:24: error: cast from pointer to integer of different size -Werror=pointer-to-int-cast] 704 | do { memstalls += ((((long) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0) | ^ Since this code simply needs to check alignment, cast it using uintptr_t which is the right type for this. --- sim/sh/interp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim/sh/interp.c b/sim/sh/interp.c index c502b21b49f..93923fa2c56 100644 --- a/sim/sh/interp.c +++ b/sim/sh/interp.c @@ -701,7 +701,7 @@ do { \ #else #define MA(n) \ - do { memstalls += ((((long) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0) + do { memstalls += ((((uintptr_t) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0) #define L(x) thislock = x; #define TL(x) if ((x) == prevlock) stalls++; -- 2.30.2