<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 - [OpenMP5.0] Clang violates OpenMP restrictions on the atomic construct"
   href="https://bugs.llvm.org/show_bug.cgi?id=46273">46273</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[OpenMP5.0] Clang violates OpenMP restrictions on the atomic construct
          </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>sulinna@cn.fujitsu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi, I am testing on OpenMP5.0 feature on clang10.0.0, 
and found clang does not conform to the OpenMP5.0 restrictions as below:

Restriction on the atomic Construct(C/C++):
All atomic accesses to the storage locations designated by x throughout the
program are required to have a compatible type.
<a href="https://www.openmp.org/spec-html/5.0/openmpsu95.html#x126-4840002.17.7">https://www.openmp.org/spec-html/5.0/openmpsu95.html#x126-4840002.17.7</a>

Test case:
---------------------------
void atomic_wrong ()
{
union {int n; float x;} u;

#pragma omp parallel
{
#pragma omp atomic update
u.n++;

 #pragma omp atomic update
 u.x += 1.0;

 /* Incorrect because the atomic constructs reference the same location
 through incompatible types */
}
}

Test command:
-----------------------------
# clang --version
clang version 10.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
# clang -fopenmp-version=50 -fopenmp -S atomic_restrict.1.c

According to OpenMP5.0 atomic restriction, atomic accesses to the same storage
location required to have a compatible type, clang is expected return an error
message when compile the testcase, but clang compiled success.

I have looked into the clang source code SemaOpenMP.cpp, and found there is no
check about the above OpenMP5.0 atomic restriction in the Class
OpenMPAtomicUpdateChecker, The OpenMP5.0 atomic restriction check should be
implemented by clang for OpenMP5.0 support.

Thanks.</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>