return
is not allowed inside the loop as it will cause exit before the curly braces.
Note the definition given below :
From the OpenMP V2.5 spec, 1.2.2 OpenMP language terminology, p2:17-
structured block - For C/C++, an executable statement, possibly
compound, with a single entry at the top and a single exit at the
bottom.
A structured block starts with the open {
and ends with the closing }
. The return
is contained within these braces, so this program also violates the OpenMP definition for a structured block, because it has two exits (one at the return
and one at the exit through the brace)
OpenMP places the following five restrictions on which loops can be threaded:
- The loop variable must be of type signed integer. Unsigned integers,
such as DWORD's, will not work.
- The comparison operation must be in the form loop_variable
<
, <=
, >
,
or >=
loop_invariant_integer
- The third expression or increment portion of the for loop must be
either integer addition or integer subtraction and by a loop
invariant value.
- If the comparison operation is
<
or <=
, the loop variable must
increment on every iteration, and conversely, if the comparison
operation is >
or >=
, the loop variable must decrement on every
iteration.
- The loop must be a basic block, meaning no jumps from the inside of
the loop to the outside are permitted with the exception of the exit
statement, which terminates the whole application. If the statements
goto or break are used, they must jump within the loop, not outside
it. The same goes for exception handling; exceptions must be caught
within the loop.