The C Standard, 22.214.171.124 [ISO/IEC 9899:2011], states that a thread shall not be joined once it was previously joined or detached. Similarly, subclause 126.96.36.199 states that a thread shall not be detached once it was previously joined or detached. Violating either of these subclauses results in undefined behavior.
Noncompliant Code Example
This noncompliant code example detaches a thread that is later joined.
This compliant solution does not detach the thread. Its resources are released upon successfully joining with the main thread:
Joining or detaching a previously joined or detached thread is undefined behavior.
|Supported, but no explicit checker|
Thread is not Joinable
Do not join or detach a thread that was previously joined or detached
|Polyspace Bug Finder|
|CERT C: Rule CON39-C||Checks for join or detach of a joined or detached thread (rule fully covered)|
Subclause 188.8.131.52, "The