Mail Archives: djgpp/2000/05/22/07:15:27
Damian Yerrick wrote:
>On 19 May 2000 13:51:00 GMT, buers AT gmx DOT de (Dieter Buerssner) wrote:
>>For DJGPP (and any C90 compiler), you can write (size_t)-1 instead
>>of SIZE_MAX.
>
>DJGPP? Yes. Any C90 compiler? No. For example, the MC68000
>microprocessor represents all sizes as 32-bit integers, but the chip
>has only 24 address lines; addresses are anded with 0x00ffffff before
>being sent out the wire. In this case, size_t would probably be
>typedef'd as unsigned long, but C99's SIZE_MAX would be 0x00ffffff not
>0xffffffff.
My reading of the Standard is different. From my understanding, when
an implementation chooses to limit size_t to 0xffffff, it must have
an unsigned integer type, that "overflows an wraps" at exactly that
value. Any assignment from a different integer type to an unsigned
integer type automatically must be modulus (UINTTYPE_MAX+1). Therefore
(UINTTYPE)-1 is always UINTTYPE_MAX.
- Raw text -