Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1][New Test] Add loop iteration count signed/unsigned corner testcase #520

Open
tob2 opened this issue Apr 22, 2022 · 0 comments
Open
Assignees
Labels
new test PR that adds new tests

Comments

@tob2
Copy link
Collaborator

tob2 commented Apr 22, 2022

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 intunsigned 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)

int
main ()
{
  int error = 0;
  #pragma omp for
  for (int i = -1000; i < 10u; ++i) {
     error = 1;
  }
  return error;
}
@tob2 tob2 added the new test PR that adds new tests label Apr 22, 2022
@spophale spophale assigned spophale and unassigned tmh97 and nolanbaker31 Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new test PR that adds new tests
Projects
None yet
Development

No branches or pull requests

4 participants