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 2.7.2.1 on page 25.
firstprivate, Section 2.7.2.2 on page 26.
lastprivate, Section 2.7.2.3 on page 27.
shared, Section 2.7.2.4 on page 27.
default, Section 2.7.2.5 on page 28.
reduction, Section 2.7.2.6 on page 28.
copyin, Section 2.7.2.7 on page 31.
copyprivate, Section 2.7.2.8 on page 32.