Should atomic_xxx() functions reject not-_Atomic() arguments ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm told this belongs here and not in glibc-help...
----------

The C11/C18 Standard defines, for <stdatomic.h>, for example:

  C atomic_fetch_<key>(volatile A *object, M operand);

where "An A refers to one of the atomic types."

So:

   _Atomic(uint64_t) foo ;
   uint64_t bar ;

   bar = atomic_fetch_add(&foo, 1) ;

is all by the book.

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 ?

On my x86_64, gcc 9.2/glibc 2.30 do not think it is an error, and indeed for the x86_64 _Atomic(uint64_t) and uint64_t are identical.

But this looks like a trap for the unwary... on some machine out there, the Standard says 'bar = atomic_fetch_add(&bar, 1) ;' is a *mistake*.

Or will gcc/glibs throw an error on such a machine ?




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux