[llvm-bugs] [Bug 49442] New: Clang failed to emit method definition in template class (e.g. std::set)
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 4 12:58:44 PST 2021
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: unassignedclangbugs at nondot.org
Reporter: ytj000 at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210304/5ac500f3/attachment.html>
More information about the llvm-bugs
mailing list