You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did run into this issue recently – and think it could be a useful addition; it just needs to be properly packaged:
Due to the int → unsigned int integer promotion, the i < 10u condition evaluates as false and the loop body is not executed.
However, depending how the OpenMP loop iteration count is calculated, it might run 1010 times.
Since OpenMP 5.1, the following wording ensures that the OpenMP count and the C count are the same:
"If var has a signed integer type and the var operand of test-expr after usual arithmetic conversions has an unsigned integer type then the loop iteration count is computed from lb, test-expr and incr using an unsigned integer type corresponding to the type of var." (OpenMP 5.2, 4.4.2 OpenMP Loop-Iteration Spaces and Vectors and, likewise, OpenMP 5.1, 2.11.1 Canonical Loop Nest Form)
intmain ()
{
interror=0;
#pragma omp for
for (inti=-1000; i<10u; ++i) {
error=1;
}
returnerror;
}
The text was updated successfully, but these errors were encountered:
I did run into this issue recently – and think it could be a useful addition; it just needs to be properly packaged:
int
→unsigned int
integer promotion, thei < 10u
condition evaluates as false and the loop body is not executed.Since OpenMP 5.1, the following wording ensures that the OpenMP count and the C count are the same:
"If var has a signed integer type and the var operand of test-expr after usual arithmetic conversions has an unsigned integer type then the loop iteration count is computed from lb, test-expr and incr using an unsigned integer type corresponding to the type of var." (OpenMP 5.2, 4.4.2 OpenMP Loop-Iteration Spaces and Vectors and, likewise, OpenMP 5.1, 2.11.1 Canonical Loop Nest Form)
The text was updated successfully, but these errors were encountered: