Node:C++98 Thread-Local Edits, Previous:C99 Thread-Local Edits, Up:Thread-Local

#### ISO/IEC 14882:1998 Edits for Thread-Local Storage

The following are a set of changes to ISO/IEC 14882:1998 (aka C++98) that document the exact semantics of the language extension.

[intro.execution]

New text after paragraph 4

> A thread is a flow of control within the abstract machine. It is implementation defined whether or not there may be more than one thread.

New text after paragraph 7

> It is unspecified whether additional action must be taken to ensure when and whether side effects are visible to other threads.

- [lex.key]

  Add `__thread`.

- [basic.start.main]

  Add after paragraph 5

  > The thread that begins execution at the `main` function is called the main thread. It is implementation defined how functions beginning threads other than the main thread are designated or typed. A function so designated, as well as the `main` function, is called a thread startup function. It is implementation defined what happens if a thread startup function returns. It is implementation defined what happens to other threads when any thread calls `exit`.

- [basic.start.init]

  Add after paragraph 4

  > The storage for an object of thread storage duration shall be statically initialized before the first statement of the thread startup function. An object of thread storage duration shall not require dynamic initialization.

- [basic.start.term]

  Add after paragraph 3

  > The type of an object with thread storage duration shall not have a non-trivial destructor, nor shall it be an array type whose elements (directly or indirectly) have non-trivial destructors.

- [basic.stc]

  Add "thread storage duration" to the list in paragraph 1.

  Change paragraph 2

  > Thread, static, and automatic storage durations are associated with objects introduced by declarations [...].

  Add `__thread` to the list of specifiers in paragraph 3.

- [basic.stc.thread]

  New section before [basic.stc.static]

  > The keyword `__thread` applied to an non-local object gives the object thread storage duration.

  > A local variable or class data member declared both `static` and `__thread` gives the variable or member thread storage duration.

- [basic.stc.static]

  Change paragraph 1

  > All objects which have neither thread storage duration, dynamic storage duration nor are local [...].

- [dcl.stc]

  Add `__thread` to the list in paragraph 1.

  Change paragraph 1

  > With the exception of `__thread`, at most one storage-class-specifier shall appear in a given decl-specifier-seq. The `__thread` specifier may be used alone, or immediately following the `extern` or `static` specifiers. [...]

  Add after paragraph 5

  > The `__thread` specifier can be applied only to the names of objects and to anonymous unions.

- [class.mem]

  Add after paragraph 6

  > Non-`static` members shall not be `__thread`.