Supposed I have the following class:
class A
{
public:
...
...
void incrementN() {++n_;}
uint64_t getN() {return n_;}
private:
std::atomic<uint64_t> n_;
...
...
};
Assume that I initialize all the other variables in the class, except n_
and that this is not thread local storage, so there is no zero initialization.
I create an object of class A, and keep calling incrementN()
.
If at some point I want the value of n_
, and I call getN()
, can this cause the load()
routine for the atomic n_
to crash?