==14825== Possible data race during write of size 1 at 0x6062C9 by thread #1
==14825== Locks held: none
==14825== at 0x4015B3: store (atomic_base.h:374)
==14825== by 0x4015B3: std::__atomic_base<bool>::operator=(bool) (atomic_base.h:267)
==14825== by 0x40130E: std::atomic<bool>::operator=(bool) (atomic:74)
==14825== by 0x40119F: main (main.cpp:21)
==14825==
==14825== This conflicts with a previous read of size 1 by thread #11
==14825== Locks held: none
==14825== at 0x401343: load (atomic_base.h:396)
==14825== by 0x401343: std::atomic<bool>::operatorbool() const (atomic:81)
==14825== by 0x401097: count1m(int) (main.cpp:11)
==14825== by 0x4037BB: void std::_Bind_simple<void (*(int))(int)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (functional:1531)
==14825== by 0x4036C7: std::_Bind_simple<void (*(int))(int)>::operator()() (functional:1520)
==14825== by 0x403657: std::thread::_Impl<std::_Bind_simple<void (*(int))(int)> >::_M_run() (thread:115)
==14825== by 0x4EF8C7F: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==14825== by 0x4C34DB6: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==14825== by 0x53DF6B9: start_thread (pthread_create.c:333)
==14825== Address 0x6062c9 is 0 bytes inside data symbol "ready"
Why? Is not the atomic boolean 'ready' supposed to be thread-safe?
Helgrind does not understand standard C++ (or for that matter C11) memory order relationships. It assumes that the program uses the crude (and by now thoroughly obsolete) concurrency primitives as specified by POSIX.
(Helgrind is also somewhat ignorant about POSIX condition variables.)