<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [OPENMP 4.5]"
   href="https://bugs.llvm.org/show_bug.cgi?id=50733">50733</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[OPENMP 4.5]
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>xiao.liu@compiler-dev.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The testcase is,

#include <stdio.h>
#define M 10
int b = 10;
int main()
{
  int a[M], i;
  #pragma omp parallel
  {
    #pragma omp for linear(b:2)
    for (i = 0; i < M; i++) {
      a[i] = b;
    }
  }
  for (i = 0; i < M; i++) {
    printf("%d  ", a[i]);
  }
  printf("\n%d\n", b);
  return 0;
}

The result is,

10  12  14  16  18  20  22  24  26  28  
final b: 30


See OpenMP 4.5 specification, 2.15.3.7

"When a linear clause is specified on a construct,(...),The value corresponding
to the sequentially last iteration of the associated loop(s) is assigned to the
original list item."

I think that the final value of 'b' should be 28. And if there is some
assignment to 'b' in the loop, like as,

    #pragma omp for linear(b:2)
    for (i = 0; i < M; i++) {
      a[i] = b;
      b += 2;
    }

The final value of 'b' should be calculate as, (28+2)=30, instead of
(10+M*2)=30.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>