Following up to this question - std::memory_order_relaxed and initialization. Suppose I have code like this
class Something {
public:
int value;
};
auto&& pointer = std::atomic<Something*>{nullptr};
// thread 1
auto value = Something{1};
pointer.set(&value, std::memory_order_relaxed);
// thread 2
Something* something = nullptr;
while (!(something = pointer.load(std::memory_order_relaxed))) {}
cout << something->value << endl;
Is this guaranteed to print 1? Can an implementation be allowed to take the address of a non initialized value?
(Assuming that there are no lifetime issues with thread 2 reading the pointer set by thread 1)