Hi Mike, after some hours of sleep I realized that your step function can do something very interesting, (which you already requested previously):
That is: create a race condition that is _always_ at 100% missed by tsan: cat lib.c /* { dg-do compile } */ /* { dg-options "-O2 -fno-sanitize=all" } */ static volatile int serial = 0; void step (int i) { while (__atomic_load_n (&serial, __ATOMIC_ACQUIRE) != i - 1); __atomic_store_n (&serial, i, __ATOMIC_RELEASE); } cat tiny_race.c /* { dg-shouldfail "tsan" } */ #include <pthread.h> void step(int); int Global; void *Thread1(void *x) { step (1); Global = 42; step (3); return x; } int main() { pthread_t t; pthread_create(&t, 0, Thread1, 0); step (2); Global = 43; step (4); pthread_join(t, 0); return Global; } /* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */ Bernd.