This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Should atomic_xxx() functions reject not-_Atomic() arguments ?
- From: Jim Wilson <jimw at sifive dot com>
- To: Chris Hall <gcc at gmch dot uk>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 27 Feb 2020 17:01:15 -0800
- Subject: Re: Should atomic_xxx() functions reject not-_Atomic() arguments ?
- References: <72f6344e-d8b2-bab4-b047-63e298063492@gmch.uk> <c339b5a2-1ac9-603d-a91d-4682533b8877@gmch.uk>
On Thu, Feb 27, 2020 at 7:20 AM Chris Hall <gcc@gmch.uk> wrote:
> Now, the Standard also tells us that _Atomic(uint64_t) and uint64_t may
> have different sizes, representations and alignment. So I guess:
> bar = atomic_fetch_add(&bar, 1) ;
> should be an error ?
__atomic_fetch_add accepts any integer or pointer type. So the fact
that _Atomic(uint64_t) and uint64_t may be different types is not a
problem, as long as they are still integer types. This works like an
overloaded function in C++.
https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/_005f_005fatomic-Builtins.html#g_t_005f_005fatomic-Builtins
Jim