[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bogus (intptr_t) casts
From: |
Dale R. Worley |
Subject: |
Re: Bogus (intptr_t) casts |
Date: |
Thu, 01 Aug 2024 12:01:48 -0400 |
Martin D Kealey <martin@kurahaupo.gen.nz> writes:
> It follows that the following assertions are allowed to fail:
>
> intptr_t i = 0;
> assert((void*)i == (void*)0);
> void *p = 0;
> assert((intptr_t)p == 0);
(After removing the bogus "*" that got inserted.)
Yeah, it looks like that's correct; there doesn't seem to be a
requirement that
> intptr_t i = 0;
> (void*)i
yields a NULL pointer.
OTOH,
> intptr_t i = (intptr_t)(void*)0;
> (void*)i
should do so.
Though I'd recommend removing use of intptr_t if at all possible, since
it violates semantic categories.
Dale