[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: texinfo-6.7.90 pretest
From: |
Gavin Smith |
Subject: |
Re: texinfo-6.7.90 pretest |
Date: |
Sat, 27 Feb 2021 20:12:05 +0000 |
User-agent: |
Mutt/1.9.4 (2018-02-28) |
On Sat, Feb 27, 2021 at 12:11:05PM +0200, Eli Zaretskii wrote:
> 2. A compilation warning in api.c:
>
> parsetexi/api.c: In function 'element_to_perl_hash':
> parsetexi/api.c:431:26: warning: cast from pointer to integer of
> different size [-Wpointer-to-int-cast]
> 431 | IV value = (IV) f;
> | ^
>
> I fixed it by casting to intptr_t first:
>
> IV value = (IV) (intptr_t) f;
>
> Is this the right fix?
According to the "perlguts" manpage:
Perl uses a special typedef IV which is a simple signed integer type
that is guaranteed to be large enough to hold a pointer (as well as an
integer). Additionally, there is the UV, which is simply an unsigned
IV.
Hence casting from f, which is a pointer, to IV should be OK, so I am
not sure why you are getting a warning here.
The current code is from commit 5057fbcc02e, where the ELEMENT * type is
cast to a long in other parts of the change (instead of IV) (in
handle_line_command in handle_commands.c). If that cast doesn't give
a warning, then changing the code in question to
IV value = (long) f;
would be a good fix. (Although I would have thought that was back-to-front
as I thought a long on MS-Windows could only be 32 bits despite a pointer
being 64 bits, while the IV type is supposed to big enough.
Otherwise, I'd be worried that intptr_t is not going to be defined on
some platform or another.
As I said in an earlier email on this issue, there is no real chance of
an overflow as the numbers stored like this are very small.