<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 early initialization for function static variable"
   href="https://bugs.llvm.org/show_bug.cgi?id=38745">38745</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang++ fails early initialization for function static variable
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.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>normal
          </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>timj@gnu.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20790" name="attach_20790" title="Demo for lack of initialization of a static variable at function scope">attachment 20790</a> <a href="attachment.cgi?id=20790&action=edit" title="Demo for lack of initialization of a static variable at function scope">[details]</a></span>
Demo for lack of initialization of a static variable at function scope

Code generated with clang version 4.0.1-6 or 6.0.0-1ubuntu2 crashes due to an
uninitialized unordered_map during execution of static ctors. The map should
have been initialized as a static variable during the first call to a singleton
accessor.
Various g++ versions (tested up to 7.2.0) produce properly working code for the
attached test case.
Note that moving the static unordered_map out of the singleton function into
global scope works and doesn't trigger the issue.</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>