- Code: Select all
#pragma omp task
int x = foo();
And if it is legal then what is the scope of variable "x" here.
The 3.1 specification says that for C/C++ structured block is an executable statement, but there is no such term in C/C++ specification. The "int x = foo();" looks very much like executable statement.
If the above code fragment is legal, then it should be semantically equivalent to either
- Code: Select all
#pragma omp task
{ int x = foo(); }
or
- Code: Select all
int x;
#pragma omp task
{ x = foo(); }
depending on the scope of "x". In the first case the variable "x" declared in the scope of task construct, and thus should be private. I the second case "x" obeys base language rules and its scope lasts until closing "}", and thus it should be stared inside the task construct, and the parallel code keeps sequential semantics.
Please help to interpret.
Thanks,
Andrey
