<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 failed to emit method definition in template class (e.g. std::set)"
   href="https://bugs.llvm.org/show_bug.cgi?id=49442">49442</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang failed to emit method definition in template class (e.g. std::set)
          </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>ytj000@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Steps to Reproduce:

Online version: <a href="https://wandbox.org/permlink/M22DS95maZND7g3X">https://wandbox.org/permlink/M22DS95maZND7g3X</a>

Basically for the following code

```
// a.h
#pragma once
#include <set>
struct Foo {
  Foo();
  ~Foo();
  std::set<int> field;
  void operator=(const std::set<int>& value) {
    field = value;
  }
};

// a.cpp
#include "a.h"
Foo::Foo() {}
Foo::~Foo() {}

// prog.cc
#include "a.h"
template <class>
void f() {
  Foo s;
  s = {24};
}

int main() {
  f<int>();
}
```

Gcc accepts the code, but clang rejects with following error message

```
/tmp/prog-66526a.o: In function `void f<int>()':
prog.cc:(.text._Z1fIiEvv[_Z1fIiEvv]+0x59): undefined reference to
`std::__1::set<int, std::__1::less<int>, std::__1::allocator<int> >::~set()'
prog.cc:(.text._Z1fIiEvv[_Z1fIiEvv]+0x8e): undefined reference to
`std::__1::set<int, std::__1::less<int>, std::__1::allocator<int> >::~set()'
/usr/bin/ld: prog.exe: hidden symbol
`_ZNSt3__13setIiNS_4lessIiEENS_9allocatorIiEEED1Ev' isn't defined
/usr/bin/ld: final link failed: Bad value
clang-13: error: linker command failed with exit code 1 (use -v to see
invocation)
```

It looks like clang did not emit `std::set<int>::~set()` in `prog.cc` while it
should.

This can be reproduced in both clang++ 7.0/9.0/trunk on CentOS 8.</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>