Tim Rentsch said:
Ben Bacarisse said:
[snip]
An implementor who hated you could in theory use 64 for all the standard
unsigned integer types except unsigned char, and then have the 16-bit
and 32-bit types be extended unsigned integer types.
I think you may be missing a much more devious possibility, namely
#define CHAR_BIT 16
typedef _Bool size_t;
As far as I can tell an implementation could have this combination
of definitions and still be conforming....
size_t sz = sizeof(long);
will leave sz == 1 if size_t is a synonym for _Bool, and that's surely
not permitted.
Have you forgotten 6.3p2?
Conversion of an operand value to a compatible type
causes no change to the value or the representation.
^^^^^^^^^^^^^^^^^^^^^^
No, not exactly. I'd forgotten that assignment does no promotion -- it
just coverts.
Is an implementation conforming if you can't pass a size_t to a function
without a prototype? I think calling
extern void *my_alloc();
long *lp = my_malloc(sizeof *lp);
does what I was trying to do -- the argument is promoted and then
assigned so it is an int that is assigned to the (non-prototype)
size_t parameter (not shown).