DEPRECATED: Race Condition in Switch

Deprecated Base
Structure: Simple
Description

This deprecated entry originally suggested a race condition could occur if a switch statement's controlling expression was evaluated multiple times. In practice, this doesn't happen—the expression is evaluated just once, making this specific scenario not a valid software weakness.

Extended Description

This entry was likely created from a misunderstanding. The original concern was about unpredictable switch behavior in multi-threaded code when the controlling expression uses variables that other threads can modify. This actual vulnerability—a Time-of-check Time-of-use (TOCTOU) race condition—is properly covered under CWE-367 (Time-of-check Time-of-use Race Condition). All major programming languages and compilers evaluate a switch control expression a single time. If a future language were designed to evaluate it multiple times, that would be intentional behavior, not a flaw. Developers concerned about thread safety in conditional logic should focus on proper synchronization and the principles outlined in CWE-367.