The C17 standard, section 7.17.2.2, states the below regardingvoid atomic_init(volatile A *obj, C value) defined in <stdatomic.h>:
Although this function initializes an atomic object, it does not avoid data races; concurrent access to the variable being initialized, even via an atomic operation, constitutes a data race.
Since the whole point of having atomic objects and atomic operations is to avoid data races, why does the atomic_init function exist? For example, why not do the below?
_Atomic int x = 7;
Instead of:
_Atomic int x;
atomic_init(&x, 7);
Also, why is it called atomic_init when it really is an assignment?