[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: |
Tue, 12 Jul 2005 16:49:26 -0400 |
User-agent: |
Mutt/1.4.2i |
On Tue, Jul 12, 2005 at 04:23:53PM +0200, Felix Nawothnig wrote:
> It also guarantees that sizeof(char) <= sizeof(short) <= sizeof(int) <=
> sizeof(long). (again I guess ISO C99 adds <= sizeof(long long))
It's a subtle point, but I don't think C99 actually guarantees this.
Instead it guarantees that the range of a smaller type is a subset of
the range of a larger type. Where "smaller" and "larger" here refer
to the "integer conversion rank" of the type.
So while SHORT_MAX must be less than or equal to INT_MAX,
sizeof(short) can be larger than sizeof(int). This is because C99
adds the concept of "padding bits" in an integer which do not
contribute to the value. I think you could have a conforming
implementation where:
short = 1 sign bit + 15 value bits + some padding bits
int = 1 sign bit + 15 value bits + no padding bits
I doubt someone would actually implement this sort of thing, but I'm
pretty sure the standard does allow it. There almost certainly are
platforms that use padding bits in some way, since otherwise there
wouldn't be much need to add the concept to the standard.
-Dave Dodge
- Re: [Tinycc-devel] casting bug?, (continued)
- 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
- Re: [Tinycc-devel] casting bug?, Felix Nawothnig, 2005/07/12
- Re: [Tinycc-devel] casting bug?, Alexander Strasser, 2005/07/18
- Re: [Tinycc-devel] casting bug?,
Dave Dodge <=
- Re: [Tinycc-devel] casting bug?, Dave Dodge, 2005/07/12
- Re: [Tinycc-devel] casting bug?, lepton, 2005/07/12