I have a multi-thread program, which behaves differently when compiled by GCC or clang (exactly the same source code; same CMakeLists.txt ).
The main difference is that when it is compiled by GCC, the internal memory buffer of the program is never cleaned (but it is when the program is compiled by clang).
The variable that is used as signal for clearing the buffer is a global atomic long integer (int64_t), shared by all the threads, and created at the beginning by the main thread. This atomic variable change during the execution, so it seems that the change is not seen by the threads.
also, see what happens if you put the volatile keyword on the variable in question.
this isnt a fix, but a test, even if it fixes it, its probably not the best solution.