<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 - -fopenmp-simd incorrectly defines _OPENMP"
   href="https://bugs.llvm.org/show_bug.cgi?id=37536">37536</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-fopenmp-simd incorrectly defines _OPENMP
          </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>normal
          </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>steffen.seckler@tum.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang incorrectly defines _OPENMP if -fopenmp-simd is specified. This should
only happen if full openmp support is available:

this shows, whether _OPENMP has been defined, based on different parameters:

<span class="quote">> clang -fopenmp-simd -dM -E - < /dev/null | grep -i openmp </span >
#define _OPENMP 201511
(this should not be defined here)

<span class="quote">> clang -fno-openmp -fopenmp-simd -dM -E - < /dev/null | grep -i openmp </span >
#define _OPENMP 201511
(this should not be defined here)

<span class="quote">> clang -fopenmp -dM -E - < /dev/null | grep -i openmp </span >
#define _OPENMP 201107
(ok, should be defined)

<span class="quote">> clang -fopenmp-simd -fopenmp -dM -E - < /dev/null | grep -i openmp </span >
#define _OPENMP 201107
(ok, should be defined)

The openmp standard provides a reference style to check for openmp support,
that is checking for the definition of _OPENMP, e.g. example from openmp
standard (<a href="https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf">https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf</a>, page 35):

<span class="quote">> #ifdef _OPENMP
> iam = omp_get_thread_num() + &index
> #endif</span >

This simple example code breaks if -fopenmp-simd is defined and -fopenmp is
not.

build environment:
clang version: 6.0.1-svn331815-1~exp1~20180510082943.84


comparison with other compilers:
g++ 7.3.0:
<span class="quote">> g++ -fopenmp-simd -dD -E - < /dev/null | grep -i openmp</span >
(empty, _OPENMP not defined)
<span class="quote">> g++ -fopenmp-simd -fopenmp -dD -E - < /dev/null | grep -i openmp</span >
#define _OPENMP 201511

icpc 16.0.4:
<span class="quote">> icpc -dD -E -qopenmp-simd - </dev/null | grep -i openmp</span >
(empty, _OPENMP not defined)
<span class="quote">> icpc -dD -E -qopenmp -qopenmp-simd - </dev/null | grep -i openmp</span >
#define _OPENMP 201307

icpc 17.0.6:
<span class="quote">> icpc -dD -E -qopenmp-simd - </dev/null | grep -i openmp</span >
(empty, _OPENMP not defined)
<span class="quote">> icpc -dD -E -qopenmp -qopenmp-simd - </dev/null | grep -i openmp</span >
#define _OPENMP 201511



P.S: it also seems, that the defined openmp versions are quite erratic (201511
if openmp has not been defined, but openmp-simd has; 201107 if openmp has ALSO
been defined)</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>