[Python-Dev] void* <-> size_t

Serhiy Storchaka storchaka at gmail.com
Sun May 13 16:28:15 CEST 2012


On 13.05.12 12:48, Stefan Krah wrote:
> The C standard doesn't guarantee sizeof(void *) == sizeof(size_t). In
> fact, there are machines where sizeof(void *)>  sizeof(size_t):
>
> http://comments.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/651
> http://www-01.ibm.com/support/docview.wss?uid=swg27019425

I noticed recently that the code is often used unsafe casting void* -> 
size_t and size_t -> void*. For example:

     const char *aligned_end = (const char *) ((size_t) end & 
~LONG_PTR_MASK);

I defer this issue until issues 14624 and 14624 will be resolved (same 
method is used in the suggested patches), but once it already mentioned, 
should be replaced size_t to Py_uintptr_t in all such castings?



More information about the Python-Dev mailing list