K
Kirk Zurell
I'm working through an (older) copy of the C standard to learn if there
is any minute difference between
char * ptr;
/* ... */
*ptr++ = 0x23;
and
char * ptr;
/* ... */
*(ptr)++ = 0x23;
owing to promotion or something obscure I don't know about.
Here's what I've concluded:
An identifier describing an object is an lvalue (6.5.1 2).
A parenthesized expression is an lvalue. Its type and value are
identical to the unparenthesized expression (6.5.1 5).
The operand of the * operator shall have pointer type (6.5.3.2 2) and is
an lvalue (6.5.3.2 4).
So, in *(ptr)++ it's required that the (ptr) expression have pointer
type. Based on this, I think *ptr++ and *(ptr)++ are identical.
Anyone spot me on this?
Thanks
Kirk
is any minute difference between
char * ptr;
/* ... */
*ptr++ = 0x23;
and
char * ptr;
/* ... */
*(ptr)++ = 0x23;
owing to promotion or something obscure I don't know about.
Here's what I've concluded:
An identifier describing an object is an lvalue (6.5.1 2).
A parenthesized expression is an lvalue. Its type and value are
identical to the unparenthesized expression (6.5.1 5).
The operand of the * operator shall have pointer type (6.5.3.2 2) and is
an lvalue (6.5.3.2 4).
So, in *(ptr)++ it's required that the (ptr) expression have pointer
type. Based on this, I think *ptr++ and *(ptr)++ are identical.
Anyone spot me on this?
Thanks
Kirk