This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60796] New: Default move constructor not generated by explicit template instantiaion (C++11)
- From: "brian.freyburger at blandertechnologies dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 09 Apr 2014 16:27:42 +0000
- Subject: [Bug c++/60796] New: Default move constructor not generated by explicit template instantiaion (C++11)
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60796
Bug ID: 60796
Summary: Default move constructor not generated by explicit
template instantiaion (C++11)
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: brian.freyburger at blandertechnologies dot com
When you use explicit template instantiation in separate compilation units, and
disable implicit instantiation, a move constructor and move assignment operator
defined as "=default" is not generated.
See example here:
A.H:
#include <memory>
template <typename T>
struct A
{
A (T*a) : a(a) {}
A(A&&) = default;
A& operator =(const A&) = default;
std::shared_ptr<T> a;
};
extern template class A<int>;
A.C:
#include "A.H"
template class A<int>;
main.C:
#include "A.H"
template class A<int>;
int main()
{
A<int> a = new int(19);
A<int> b = std::move(a);
}
results:
g++ -std=c++11 A.C main.C
/tmp/ccvE1IqS.o: In function `main':
main.C:(.text+0xdc): undefined reference to `A<int>::A(A<int>&&)'
collect2: error: ld returned 1 exit status