clanguage-lawyerthread-local-storagestorage-duration

Are "thread storage duration" and "thread local storage duration" the synonyms?


C11, 6.2.4 Storage durations of objects, 4 (emphasis added):

An object whose identifier is declared with the storage-class specifier _Thread_local has thread storage duration.

C11, 7.5 Errors <errno.h>, 2 (emphasis added):

errno which expands to a modifiable lvalue 201) that has type int and thread local storage duration

Are "thread storage duration" and "thread local storage duration" the synonyms?


Extra note: currently the support of _Thread_local is independent of __STDC_NO_THREADS__ while it is (probably) expected to be dependent.


Solution

  • Are "thread storage duration" and "thread local storage duration" the synonyms?

    That's the only plausible interpretation I see, yes. The definition of storage duration in paragraph 6.2.4/1 of the spec does not include a "thread local storage duration":

    There are four storage durations: static, thread, automatic, and allocated.

    However, thread storage duration is the storage duration of identifiers declared with the _Thread_local storage class specifier, and it is fairly common in general discussion to describe the objects associated with such identifiers as "thread local". I take the appearance of "thread local storage duration" in in section 7.5 -- which is the only appearance of that term in the spec -- to constitute an editorial error, but I don't think the intended meaning is in doubt. This is reinforced by the spec's remarks that

    The value of errno in the initial thread is zero at program startup (the initial value of errno in other threads is an indeterminate value)

    (C11 7.5/3).

    That errno may have different values in different threads can be explained in only two ways:

    1. errno has thread storage duration, OR
    2. this is a special, unique characteristic of errno, provided by some means other than it having thread storage duration.

    I find explanation (2) altogether implausible in light of the spec overall.