|
From: | Paul Eggert |
Subject: | Re: pdumper on Solaris 10 |
Date: | Tue, 17 Dec 2024 11:10:45 -0800 |
User-agent: | Mozilla Thunderbird |
On 2024-12-15 03:13, Eli Zaretskii wrote:
Date: Sun, 15 Dec 2024 10:55:49 +0000 From: Pip Cet<pipcet@protonmail.com> "Eli Zaretskii"<eliz@gnu.org> writes:CC igc.o igc.c: In function 'weak_hash_table_entry': igc.c:4102:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 4102 | client = (mps_addr_t)entry.intptr; | ^ igc.c:4107:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 4107 | client = (mps_addr_t)real_ptr; | ^
...
What's the preferred way of avoiding a compiler warning in this case? A simple double cast (first to uintptr_t, then to mps_addr_t) should work, right?I'll defer to Paul (CC'ed), but my personal preference is also to explicitly reset the ignored bits by bitwise AND.
The usual way I avoid such warnings is a single cast of the pointer to uintptr_t (or to intptr_t, if the eventual destination is signed).
There is no need for two casts, or for a bitwise AND, and I usually avoid these needless operations as they can be more trouble than they're worth: they introduce more hassle for maintainers and more possibilities for bugs.
[Prev in Thread] | Current Thread | [Next in Thread] |