[Python-Dev] Re: sre warnings

Martin v. Loewis martin at v.loewis.de
Sat Jan 10 16:53:45 EST 2004

Sjoerd Mullender wrote:

> If sizeof(int) < sizeof(size_t), is it *guaranteed* that (size_t)-1 
> expands to a bit pattern of all 1's? 

As Tim explains: If you assume that the machine uses two's complement,
then yes. However, this is irrelevant. More interestingly: Is it
guaranteed that you get the largest possible value of size_t? Based
on the language spec fragment that Tim cites: yes.

This actually isn't really relevant either. Is it guaranteed that
you get a value of size_t different from all values that denote
real sizes of things? To this, the answer clearly is no: There might
be objects whose size is (size_t)-1. However, it is unlikely
(perhaps even *unlikely* :-) that you ever meet such an object
in real life.

By definition, (size_t)-1 == ~(size_t)0 in all conforming


More information about the Python-Dev mailing list