Atomic And Still Wrong

// snippet A, run by two threads
std::atomic<int> balance{50};
if (balance.load() >= 50)
    balance.fetch_sub(50);

// snippet B, run by two threads
int counter = 0;
counter++;

Classify each.

A

Neither is a data race; int is word sized, so its loads and stores are already atomic

B

A has a race condition but no data race; B has a data race, so its behaviour is undefined

C

Both contain data races

D

A has a data race because two threads touch balance; B is fine because ++ compiles to one instruction