<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 - Destructor not generated for std::function<void()>"
   href="https://bugs.llvm.org/show_bug.cgi?id=33778">33778</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Destructor not generated for std::function<void()>
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>alex@xnor.ai
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18787" name="attach_18787" title="reduced test case">attachment 18787</a> <a href="attachment.cgi?id=18787&action=edit" title="reduced test case">[details]</a></span>
reduced test case

When compiling the attached case.cc with Clang,
std::function<void()>::~function() is not generated, causing a link failure:

% clang++ -std=c++11 case.cc
/tmp/case-042075.o: In function `foo(std::function<void ()> const&)':
case.cc:(.text+0x79): undefined reference to `std::function<void
()>::~function()'
clang-4.0: error: linker command failed with exit code 1 (use -v to see
invocation)

GCC does generate ~function() in this case, however:

% g++ -std=c++11 case.cc
% # OK

The problem seems to occur under both libstdc++ and libc++.  I have also
attached a reduced version of the preprocessed code (using libstdc++),
case-pp.cc, demonstrating the same problem.  (case-pp.cc will have additional
link errors for function::function(function const&) which are expected)

I have tested this on:

- clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final), target:
x86_64-pc-linux-gnu
- Apple LLVM version 8.1.0 (clang-802.0.42), target: x86_64-apple-darwin16.6.0
- clang version 4.0.1 (tags/RELEASE_401/final), target:
x86_64-unknown-linux-gnu</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>