"Grizlyk" <> wrote in news:epl9fa$f00$:
> Andre Kostur wrote:
>>> I think, the following expression
>>> unsigned char * p =
>>> static_cast<unsigned char *>
>>> (
>>> const_cast<char*>("abcdg")
>>> );
>>> is do not work because sizeof("type") can be not equal
>>> to sizeof("unsigned type") in theory
>>
>> So? That code is casting pointers-to-object. The pointer size won't
>> change, regardless of the size of the pointed to object.
>
> I am not shure (i have no standard) that pointers for all types must
> have fixed sizeof() (as "int" for example) or unsigned type must have
> the same sizeof() as signed type.
>
> For example there are memory models, where "sizeof(char *_far)==4",
> but "sizeof(char *)==2".
sizeof(char * _far) is a non-standard type, and thus is implementation-
dependant. All Standard pointers-to-object have the same size.
> Let pointers have fixed sizeof() and sizeof("type")!=sizeof("unsigned
> type"). Here pointer arithmetic can be changed, because value of next
> pointer (++ptr) is depending from size of object pointer point to.
Pointer arithmetic has nothing to do with sizeof(T*). But is related to
sizeof(T).
|