<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Segfault when assigning map of default-ctr'ed (int, function)"
   href="https://llvm.org/bugs/show_bug.cgi?id=28469">28469</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault when assigning map of default-ctr'ed (int, function)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bbannier@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Assigning a non-empty map of (int, function) segfaults for me with
optimizations.

Reproducer:

    #include <functional>
    #include <map>

    struct F {
      std::map<int, std::function<void()>> m;
      F() { m[42] = []() {}; }
    };

    int main() {
      F f;
      f = F{};
    }

Gives:

    % clang++  -O2 --std=c++11 f.cpp && ./a.out
    [1]    12965 segmentation fault  ./a.out`

I would have expected this program to run to termination successfully.

I am using clang and libcxx tracking HEAD pretty closely,

    % clang++ --version
    clang version 3.9.0 (<a href="http://llvm.org/git/clang">http://llvm.org/git/clang</a>
8dd4631f9110e39089b89284ce3ddc476f75820e) (<a href="http://llvm.org/git/llvm">http://llvm.org/git/llvm</a>
baa0bfe5d8f558f0785bd9e07d29d660461e291f)
    Target: x86_64-apple-darwin14.5.0
    Thread model: posix

My HEAD of libcxx is

    git-svn-id: <a href="https://llvm.org/svn/llvm-project/libcxx/trunk@273840">https://llvm.org/svn/llvm-project/libcxx/trunk@273840</a>
91177308-0d34-0410-b5e6-96231b3b80d8

This program appears to terminate successfully with the following builds from
homebrew,

    % clang++-3.4 --version
    clang version 3.4.2 (tags/RELEASE_34/dot2-final)
    Target: x86_64-apple-darwin16.0.0
    Thread model: posix

    % clang++-3.6 --version
    clang version 3.6.2 (tags/RELEASE_362/final)
    Target: x86_64-apple-darwin16.0.0
    Thread model: posix</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>