Re: Unexpected behavior of gcc on pointer dereference & increment
> On Sep 1, 2023, at 12:35 PM, Tomas Bortoli via Gcc wrote: > > Hi, > > I recently discovered that the following C statement: > > pointer++; > > is semantically equivalent to the following: > > *pointer++; > > Is this due to operators' priority? To me, that looks weird. Yes, https://en.cppreference.com/w/c/language/operator_precedence shows that. Liberal use of parentheses is a very good practice. paul
Re: Unexpected behavior of gcc on pointer dereference & increment
On Fri, Sep 1, 2023 at 12:37 PM Tomas Bortoli via Gcc wrote: > Hi, > > I recently discovered that the following C statement: > > pointer++; > > is semantically equivalent to the following: > > *pointer++; > > Is this due to operators' priority? To me, that looks weird. > Equivalent in the effect, but not the value. As you suspect, this is due to operator precedence. https://en.cppreference.com/w/c/language/operator_precedence This is probably more appropriate for gcc-help or a general forum about the C Language. https://stackoverflow.com/questions/68829154/c-operator-precedence-postfix-increment-and-dereference Thanks, David
Unexpected behavior of gcc on pointer dereference & increment
Hi, I recently discovered that the following C statement: pointer++; is semantically equivalent to the following: *pointer++; Is this due to operators' priority? To me, that looks weird. Thanks in advance, Tomas