Issue 1119: Meaning of TSS_DTOR_ITERATIONS

Authors: Jay Ghiron
Date: 2026-10-09
Submitted against: C23
Status: Open

TSS_DTOR_ITERATIONS

which expands to an integer constant expression representing the maximum number of times that destructors will be called when a thread terminates.

(C23 7.28.1 "Introduction" paragraph 3.)

For every thread-specific storage key which was created with a non-null destructor and for which the value is non-null, thrd_exit sets the value associated with the key to a null pointer value and then invokes the destructor with its previous value. The order in which destructors are invoked is unspecified.

If after this process there remain keys with both non-null destructors and values, the implementation repeats this process up to TSS_DTOR_ITERATIONS times.

(C23 7.28.5.5 "The thrd_exit function" paragraphs 2 and 3.)

Question 1

In the definition of TSS_DTOR_ITERATIONS it is stated that TSS_DTOR_ITERATIONS represents the maximum number of times that destructors will be called, while in the definition of thrd_exit it is stated that TSS_DTOR_ITERATIONS represents the maximum number of times that destructors being called will be repeated. Those definitions give contradictory maxima, which was the intent? For example, if TSS_DTOR_ITERATIONS is defined as one would it be valid to repeat calling the destructors?

Question 2

Can TSS_DTOR_ITERATIONS be negative? There does not appear to be anything specifically forbidding it, though the meaning of the text defining TSS_DTOR_ITERATIONS would be unclear with such a definition.

Question 3

If the answer to question one is that the maximum described in the definition of TSS_DTOR_ITERATIONS is correct, can TSS_DTOR_ITERATIONS be zero?