[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tcg: pointer size warning on x32 arch
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: tcg: pointer size warning on x32 arch |
Date: |
Sat, 11 Sep 2021 23:06:46 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 9/11/21 7:50 PM, Michael Tokarev wrote:
> Hi.
>
> The following warning is reported by the C compiler when compiling
> tcg code on x32 architecture:
>
> In file included from ../../tcg/tcg.c:429:
> tcg/i386/tcg-target.c.inc: In function ‘tcg_out_movi_int’:
> tcg/i386/tcg-target.c.inc:959:30: warning: cast to pointer from integer
> of different size [-Wint-to-pointer-cast]
> 959 | diff = tcg_pcrel_diff(s, (const void *)arg) - 7;
Likely fixed by:
---
diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc
index 98d924b91a8..0895f5670a1 100644
--- a/tcg/i386/tcg-target.c.inc
+++ b/tcg/i386/tcg-target.c.inc
@@ -956,7 +956,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType
type,
}
/* Try a 7 byte pc-relative lea before the 10 byte movq. */
- diff = tcg_pcrel_diff(s, (const void *)arg) - 7;
+ diff = tcg_pcrel_diff(s, (const void *)(uintptr_t)arg) - 7;
if (diff == (int32_t)diff) {
tcg_out_opc(s, OPC_LEA | P_REXW, ret, 0, 0);
tcg_out8(s, (LOWREGMASK(ret) << 3) | 5);
---