<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 - When compiling with `-fopenmp` clang will under certain circumstances not produce symbols for const or constexpr static data members."
   href="https://bugs.llvm.org/show_bug.cgi?id=37918">37918</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>When compiling with `-fopenmp` clang will under certain circumstances not produce symbols for const or constexpr static data members.
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chris@detrino.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This seems to happen when the following is true:

- A const or constexpr static data member is declared in a class.
- The data member is ODR-used before its definition is seen.
- The TU is compiled with `-fopenmp`
- This all happens in the global namespace.

A reduced test-case:

    // Section A - Define a class with a static constexpr data member.
    struct Foo {
      static constexpr int bar = 1;
    };

    // Section B - ODR-use the data member.
    void F(const int&);
    void Test() { F(Foo::bar); }

    // Section C - Define the data member.
    constexpr int Foo::bar;

In this example, the `Foo::bar` symbol will not be produced in the output
.s/.o. This can be worked around by moving `Section C` before `Section B`. See
<a href="https://godbolt.org/g/LrzUvY">https://godbolt.org/g/LrzUvY</a> for a live demo.</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>