All challenges
Multiple ChoiceBeginner 45s

compare_exchange_weak vs strong spurious failure

What is the key behavioral difference between compare_exchange_weak and compare_exchange_strong?
Options
  1. 1weak is always faster because it never fails
  2. 2strong can modify the expected value only on failure
  3. 3weak may fail spuriously even when the comparison succeeds
  4. 4weak works only with std::atomic<bool>

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle