Document: N1743
Date: 2013-08-24
Subject: Suggested Technical Corrigendum for DR 416
Author: Douglas Walls
Referenes: N1687, DR416, DR424


This suggested TC for DR 416 is an adaptation of the suggested TC in paper N1687.

Suggested Technical Corrigendum for DR 416

After 7.26.5.1 paragraph 2, add

Returning from func shall have the same behavior as invoking thrd_exit with the returned value.

Change 7.26.5.5, replace paragraph 2 with

For every thread specific storage key which was created with a non-null destructor and for which the value is non-null, thrd_exit shall set the value associated with the key to NULL and then invoke 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 shall repeat this process up to TSS_DTOR_ITERATIONS times.

Following this, the thrd_exit function terminates execution of the calling thread and sets its result code to res.

After 7.26.6.1 paragraph 2, add the following new paragraphs

The value NULL shall be associated with the newly created key in all existing threads.  Upon thread creation, the value associated with all keys shall be initialized to NULL.

Destructors associated with thread specific storage are not invoked at process exit.

A call to tss_create from within a destructor results in undefined behavior.

7.26.6.2 paragraph 2, add the following new second sentence

A call to tss_delete function results in undefined behavior if the call to tss_create which set key completed after the thread commenced executing destructors.

After 7.26.6.2 paragraph 2, add the following new paragraphs

If tss_delete is called while another thread is executing destructors, whether this will affect the number of invocations of the destructor associated with key on that thread is unspecified.  If the thread from which tss_delete is invoked is executing destructors, then no further invocations of the destructor associated with key will occur on that thread.

Calling tss_delete will not result in the invocation of any destructors.

7.26.6.3 paragraph 2, add the following new second sentence

A call to tss_get function results in undefined behavior if the call to tss_create which set key completed after the thread commenced executing destructors.

7.26.6.4 paragraph 2, add the following new second sentence

A call to tss_set function results in undefined behavior if the call to tss_create which set key completed after the thread commenced executing destructors.

After 7.26.6.4 paragraph 2, add the following new paragraph

This action will not invoke the destructor associated with the key on the value being replaced.*)

*) This clarifies whether or not a destructor will be invoked for storage created after a thread has already begun executing destructors: because tss_set is an undefined operation, a value may never be associated with the storage and therefore the destructor may never be invoked.