https://bugs.llvm.org/show_bug.cgi?id=49442

            Bug ID: 49442
           Summary: Clang failed to emit method definition in template
                    class (e.g. std::set)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Steps to Reproduce:

Online version: https://wandbox.org/permlink/M22DS95maZND7g3X

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to