public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Chris Hall <gcc@gmch.uk>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Are atomic_fetch_xxx() functions broken for atomic-pointer types ?
Date: Tue, 03 Mar 2020 17:14:00 -0000	[thread overview]
Message-ID: <CAH6eHdS6wgvyri0SkS05UE3z19=MRve3BgZNh+Pr+96oPe8-xg@mail.gmail.com> (raw)
In-Reply-To: <fd87379f-52e6-c0f9-3404-d41d72fee3b3@gmch.uk>

On Tue, 3 Mar 2020 at 17:11, Chris Hall <gcc@gmch.uk> wrote:
>
>
> Another <stdatomic.h> issue ?
>
> -----
>
> In Section 7.17.7.5 "The atomic_fetch and modify generic functions", the
> C11/C18 Standards say:
>
>    1 The following operations perform arithmetic and bitwise
>      computations. All of these operations are applicable to an
>      object of any atomic integer type. ...
>
>    5 NOTE The operation of the atomic_fetch and modify generic functions
>           are nearly equivalent to the operation of the corresponding
>           op= compound assignment operators. The only differences are
>           that the compound assignment operators are not guaranteed to
>           operate atomically, and the value yielded by a compound
>           assignment operator is the updated value of the object,
>           whereas the value returned by the atomic_fetch and modify
>           generic functions is the previous value of the atomic object.
>
> So given:
>
>    _Atomic(uint64_t*) foo ;
>    uint64_t* bar ;
>
>    bar = atomic_fetch_add(&foo, 1) ;
>
> why do gcc 9.2/glibc 2.30 add 1 and not 8 to the address ?

That's https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64843

  reply	other threads:[~2020-03-03 17:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <174d5d4b-b983-b4b3-9313-d71992f3c6c2@gmch.uk>
2020-03-03 17:11 ` Chris Hall
2020-03-03 17:14   ` Jonathan Wakely [this message]
2020-03-05 16:01     ` Chris Hall
2020-03-03 17:35   ` Martin Sebor

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='CAH6eHdS6wgvyri0SkS05UE3z19=MRve3BgZNh+Pr+96oPe8-xg@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gcc@gmch.uk \
    /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).