2.7.2 Data-Sharing Attribute Clauses
Several directives accept clauses that allow a user to control the sharing attributes of variables for the duration of the region. Sharing attribute clauses apply only to variables in the lexical extent of the directive on which the clause appears. Not all of the following clauses are allowed on all directives. The list of clauses that are valid on a particular directive are described with the directive.
If a variable is visible when a parallel or work-sharing construct is encountered, and the variable is not specified in a sharing attribute clause or threadprivate directive, then the variable is shared. Static variables declared within the dynamic extent of a parallel region are shared. Heap allocated memory (for example, using malloc() in C or C++ or the new operator in C++) is shared. (The pointer to this memory, however, can be either private or shared.) Variables with automatic storage duration declared within the dynamic extent of a parallel region are private.
Most of the clauses accept a variable-list argument, which is a comma-separated list of variables that are visible. If a variable referenced in a data-sharing attribute clause has a type derived from a template, and there are no other references to that variable in the program, the behavior is undefined.
All variables that appear within directive clauses must be visible. Clauses may be repeated as needed, but no variable may be specified in more than one clause, except that a variable can be specified in both a firstprivate and a lastprivate clause.
The following sections describe the data-sharing attribute clauses:
private, Section 220.127.116.11 on page 25.
firstprivate, Section 18.104.22.168 on page 26.
lastprivate, Section 22.214.171.124 on page 27.
shared, Section 126.96.36.199 on page 27.
default, Section 188.8.131.52 on page 28.
reduction, Section 184.108.40.206 on page 28.
copyin, Section 220.127.116.11 on page 31.
copyprivate, Section 18.104.22.168 on page 32.