What is a Data Race versus a Race Condition? Can you have one without the other?

Last updated 21 June 2026

  • Data race: two threads access the same memory concurrently, at least one writes, with no synchronization. It is undefined behavior under the C++ memory model (detectable by ThreadSanitizer).

  • Race condition: a broader logic bug where the result depends on timing or interleaving (e.g. check-then-act).

  • Either can exist alone: properly locked accesses can still form a wrong sequence (TOCTOU). A seemingly benign unsynchronized access is still UB even without visible bugs, so never rely on it.

  • https://utkrusht.ai/blog/cplusplus-interview-questions
  • https://roadmap.sh/questions/cpp
  • https://internshala.com/blog/cpp-coding-interview-questions/
All C++ interview questions