public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Edelsohn <dje.gcc@gmail.com>
To: Tomas Bortoli <tomasbortoli@gmail.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Unexpected behavior of gcc on pointer dereference & increment
Date: Fri, 1 Sep 2023 12:50:18 -0400	[thread overview]
Message-ID: <CAGWvnykMoYFv3aiA88Nt5LWPdYCwm9OJK8CUzU5xSyKPEYWW5A@mail.gmail.com> (raw)
In-Reply-To: <CAAHj5qiDgnHadcgSj1-80sqj8szRs_7XanjvLFkbg2DLTVjULA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 687 bytes --]

On Fri, Sep 1, 2023 at 12:37 PM Tomas Bortoli via Gcc <gcc@gcc.gnu.org>
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

  reply	other threads:[~2023-09-01 16:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-01 16:35 Tomas Bortoli
2023-09-01 16:50 ` David Edelsohn [this message]
2023-09-01 16:54 ` Paul Koning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGWvnykMoYFv3aiA88Nt5LWPdYCwm9OJK8CUzU5xSyKPEYWW5A@mail.gmail.com \
    --to=dje.gcc@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=tomasbortoli@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).