Consider the code:
#include <atomic>
#include <iostream>
struct stru {
int a{};
int b{};
};
int main() {
std::atomic<stru> as;
auto s = as.load();
std::cout << s.a << ' ' << s.b << std::endl;
}
Note that although stru
has default member initializer, it still qualifies as an aggregate type since C++14. std::atomic
has a trivial default constructor. According to the standard, should the members of as
be initialized to zero? clang 6.0.0 doesn't do this (see here), while gcc 7.2.0 seems so (see here).