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

--- Comment #5 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
(In reply to jos...@codesourcery.com from comment #3)
> The first question is whether this code is actually valid.

To my reading, the C11 standard says that these operations must work on all
atomic integer types, must be disallowed on atomic_bool, and it's unspecified
if they work on any other type. However, since GCC allows them for an
atomic-qualified pointer, the other rules in 7.17.7.5 apply.

I'm not at all confident that is the intended reading, though: in the C++
specification, from which the C specification was derived, there are overloads
of atomic_fetch_add for each atomic-integral type, plus overloads for
atomic<T*>, making it mandatory to handle the pointer case. I think this is
merely a bug in C11's spec, and this wording should also allow pointers, but
AFAICS it's not in C11's DR list.

Reply via email to