[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bogus (intptr_t) casts
From: |
Chet Ramey |
Subject: |
Re: Bogus (intptr_t) casts |
Date: |
Tue, 6 Aug 2024 14:15:26 -0400 |
User-agent: |
Mozilla Thunderbird |
On 8/6/24 9:36 AM, Martin D Kealey wrote:
Why just those ones? Mainly:
(a) I'm looking at patching that area of the code for other reasons, so
they're the ones that I happened to encounter; and
(b) I didn't want to over-cook it, so I only included the ones where I
could see that it was actually a pointer (casting a number to an intptr_t
doesn't result in UB).
Other cases that involve casting a pointer to an intptr_t or uintptr_t, and
then comparing against a *numeric* zero should be similarly updated.
You didn't address the other part of my message. Since the pointers that
are in unwind-protects are the result of byte copies, not assignments, the
compiler's representation of NULL pointers isn't relevant.
To my knowledge all current compilers use a numeric zero to represent
NULL, but this is not guaranteed, and might change in the future.
It doesn't matter. The four (or eight) bytes in the (void *) that is cast
to an intptr_t are the result of copying the original four (or eight) bytes
in the int that's being saved.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/