https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78158
--- Comment #3 from Dmitry Vyukov <dvyukov at google dot com> --- Also reported on stackoverflow: http://stackoverflow.com/questions/37552866/why-does-threadsanitizer-report-a-race-with-this-lock-free-example I've checked with gcc version 7.0.1 20170307 (experimental) (GCC) with -O0 false race is reported with -O1 no false races reported. Again atomic operation somehow end up being non-instrumented with -O0.