e.g.
int a = 3;
int b = sizeof(++a);
int c = a;
Is c equal to 3 or 4 as the result? Does the result depend on the specific compiler?
e.g.
int a = 3;
int b = sizeof(++a);
int c = a;
Is c equal to 3 or 4 as the result? Does the result depend on the specific compiler?
The specification states that the increment operator does NOT take affect when used within a sizeof
operator.
This also makes sense from an abstract viewpoint. Specifically, the sizeof
operator returns the number of bytes used by an object. While incrementing an integer or even a pointer does NOT change the size of that integer, the ++ operator would mis-lead a new programmer into thinking the size does change.
If interested look-up the topic "side-effects" for more discussion about this subject.