Are atomic_fetch_xxx() functions broken for atomic-pointer types ?
Jonathan Wakely
jwakely.gcc@gmail.com
Tue Mar 3 17:14:00 GMT 2020
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
More information about the Gcc-help
mailing list