<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 - Clang fails to compile OpenMP code using iterators to iterate through a loop on C++20"
   href="https://bugs.llvm.org/show_bug.cgi?id=48697">48697</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang fails to compile OpenMP code using iterators to iterate through a loop on C++20
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>Clang Compiler Support
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>tbsteinb@live.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24366" name="attach_24366" title="A sample piece of source code which triggers the bug">attachment 24366</a> <a href="attachment.cgi?id=24366&action=edit" title="A sample piece of source code which triggers the bug">[details]</a></span>
A sample piece of source code which triggers the bug

When compiling code which uses OpenMP to parallelize a for loop using
iterators, and compiling with `-std=c++20`, compilation fails with the
following error:

error: condition of OpenMP for loop must be a relational comparison ('<', '<=',
'>', '>=', or '!=') of loop variable 'v'
        for(auto v = vec.begin(); v < vec.end(); ++v) {

Steps to reproduce:
1) Write some code which uses OpenMP to parallelize a for loop using iterators
(I attached a file which does this).
2) Compile the code in Clang with the flags `-fopenmp -std=c++20`.

Actual behavior:
The code fails to compile giving the error listed above.

Expected behavior:
The code should successfully compile.

Date and Build:
I first saw this bug in July of 2020. I only tracked it down to using C++20 as
of January 2021 though.

Additional Information:
I've seen this error on Clang 10, 11, and on trunk (I have not tested anything
earlier than 10).
I have seen this bug on multiple Linux distros, but have not tested it on other
operating systems.
The bug only occurs if you use iterators for the for loop, indices work as
expected.</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>