[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] casting bug?

From: Dave Dodge
Subject: Re: [Tinycc-devel] casting bug?
Date: Mon, 11 Jul 2005 14:59:17 -0400
User-agent: Mutt/1.4.2i

On Mon, Jul 11, 2005 at 05:37:37PM +0200, Felix Nawothnig wrote:
> address@hidden wrote:
> >I believe that assignment should be the same as,
> >
> >  x = 0;
> No. Casting a pointer to an integer results in undefined behaviour (in 

In C99, the implementation can optionally provide the types intptr_t and
uintptr_t.  In that case you can reliably convert a void pointer to one
of those types and back again.

That said, it is unlikely that intptr_t would be the same type as
char.  And even if those types are present, the standard still doesn't
guarantee any correspondence between a specific integer value and a
specific pointer value; merely that a pointer can be converted to some
integer value that then converts back to the same pointer again.

The standard definitely does not guarantee that a null pointer is the
same as all-bits-zero.  There have been a few real implementations
that used nonzero bits.


                                                  -Dave Dodge

reply via email to

[Prev in Thread] Current Thread [Next in Thread]