On Mon, Jul 04, 2016 at 03:15:17PM -0400, D. Hugh Redelmeier wrote:
> Let me be clearer.  A pointer value that is null must test equal to
> zero.  Not true of the raw bytes of a null pointer (no conversion
> happens when you deal with the raw bytes of a pointer).
> 
> void *p;
> ...
>       passert(NULL = 0);      /* must not fail */
> ...
>       memset(&p, 0, sizeof(p));
>       passert(p == 0);        /* may fail */
> ...
>       p = 0;
>       passert(p == 0);        /* must not fail */
> ...
>       static const unsigned char zeros[sizeof(void *)];
>       p = 0;
>       passert(memcmp(&p, zeros, sizeof(void*)) == 0); /* may fail */
> 
> Some machines with segmented memory take advantage of this liberty.
> But most of those have died out.

So did their compiler explicitly handle a cast of a 0 value integer to
a pointer and map it to the "correct" null pointer address value?

That seems horribly complicated to manage.

-- 
Len Sorensen
_______________________________________________
Swan-dev mailing list
[email protected]
https://lists.libreswan.org/mailman/listinfo/swan-dev

Reply via email to