Is the following guaranteed to print 1 followed by 2?
auto&& atomic = std::atomic<int>{0};
std::atomic<int>* pointer = nullptr;
// thread 1
auto&& value = std::atomic<int>{1};
pointer = &value;
atomic.store(1, std::memory_order_relaxed);
while (atomic.load(std::memory_order_relaxed) != 2) {}
cout << value.load(std::memory_order_relaxed) << endl;
// thread 2
while (atomic.load(std::memory_order_relaxed) != 1) {}
cout << pointer->load(std::memory_order_relaxed); << endl;
pointer->fetch_add(1, std::memory_order_relaxed);
atomic.store(2, std::memory_order_relaxed) {}
If not, what are the possible outputs here? What does the standard say about initialization and memory orders for this case?