tags:

views:

137

answers:

1

Hi C++ gurus,

Let me first clarify that I am by now very familiar with definitions of size_t and intptr_t, and I don't want any repetitions of what they accomplish.

Instead I would like to know the following. Do you know of any platform, except x86/DOS (with its unbearable memory models) where the cast

void* a = ...;
size_t b = (size_t)a;

actually loses bits or bytes?

Thanks!

+2  A: 

AFAIK, on AS/400 pointers are 128-bit, but size_t is defined to be 32-bit.

elder_george
Interesting! What does sizeof(long) yield?
Jonas Byström
that seems that long is [64-bit](http://search400.techtarget.com/tip/0,289483,sid3_gci1114170,00.html) but can't say for sure.
elder_george
A more important question is: Can you provide an example of where casting a pointer to size_t is valid code?
Mitch Wheat
It is always valid to cast a pointer to `size_t`. What you can validly do with the result is another question.
Steve Jessop