[llvm-bugs] [Bug 33778] New: Destructor not generated for std::function<void()>

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 13 19:12:58 PDT 2017


            Bug ID: 33778
           Summary: Destructor not generated for std::function<void()>
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: alex at xnor.ai
                CC: llvm-bugs at lists.llvm.org

Created attachment 18787
  --> https://bugs.llvm.org/attachment.cgi?id=18787&action=edit
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
clang-4.0: error: linker command failed with exit code 1 (use -v to see

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:
- 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:

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170714/f26b0cd2/attachment.html>

More information about the llvm-bugs mailing list