My question is simple: is there any parallel algorithm where using an object of a trivial type
T is legal and safe (well defined, guaranteed to work) and using instead an
std::atomic<T> object leads to unspecified or undefined behavior? In other words, it is possible for a non atomic type to provide stronger guarantees than an atomic type?
Are all the guarantees of memory visibility valid for atomic object when they are valid for regular objects?
[That would mean that a compiler could treat (relaxed) atomic and non atomic operations the same, simplifying intermediate representation.]
If yes, is that formally provable?
Of course types
T such that
std::atomic<T> isn't a valid specialization of
std::atomic don't count.