[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
> ANSI/ISO C)
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.
http://www.eskimo.com/~scs/C-faq/q5.17.html
-Dave Dodge
- [Tinycc-devel] casting bug?, charlesrandall4-tinycc, 2005/07/11
- Re: [Tinycc-devel] casting bug?, Felix Nawothnig, 2005/07/11
- Re: [Tinycc-devel] casting bug?,
Dave Dodge <=
- Re: [Tinycc-devel] casting bug?, Felix Nawothnig, 2005/07/11
- Re: [Tinycc-devel] casting bug?, Dave Dodge, 2005/07/11
- Re: [Tinycc-devel] casting bug?, Greg Haerr, 2005/07/11
- Re: [Tinycc-devel] casting bug?, Henrik Nordstrom, 2005/07/11
- Re: [Tinycc-devel] casting bug?, Alexander Strasser, 2005/07/12
- Re: [Tinycc-devel] casting bug?, Felix Nawothnig, 2005/07/12
- Re: [Tinycc-devel] casting bug?, Alexander Strasser, 2005/07/12
- Re: [Tinycc-devel] casting bug?, Felix Nawothnig, 2005/07/12
- Re: [Tinycc-devel] casting bug?, Alexander Strasser, 2005/07/12
- Re: [Tinycc-devel] casting bug?, Dave Dodge, 2005/07/12