Thomas J. Gritzan
11/30/2008 1:07:00 AM
juanvicfer wrote:
>>> If I change line 46 to:
>>> double *pd = (double *)((int *)px1++);
>>> The pointer doesn't increment as shown by the output at stdout.
>> Doesn't increment? Sorry, but that doesn't make any sense. Nowhere in
>> your code after line 46 I see anything that would demonstrate whether
>> the pointer got incremented or not. You don't output the new value of
>> 'px1', you don't output anything that depends on the new value of 'px1'.
>> What made you conclude that it doesn't increment then?
>
> I suppose that he is expecting to have the address of px1 + size_of
> (int);
>
> This can be achieved with the following expression:
>
> double *pd = (double *)(++(int *)px1);
This doesn't (or should not) compile. (int*)px1 yields an rvalue in this
case, but the increment operator only works on lvalues, because it
changes the operand.
> , although the behaviour is undefined in this case
--
Thomas