I have this weird bug which I cannot wrap my head around. I've reduced it to a simple example. I can fix it by creating an empty destructor, but I would really like to know what is going on.
#include <cstdio>
#include <functional>
struct test {
inline test()
{}
const std::function<void()> f;
const int universe = 42;
};
template<size_t n = 1>
inline void do_test(const test& t = {}) {
printf("%d\n", t.universe);
}
int main(int, char**) {
// test t;
do_test();
return 0;
}
This will not compile, outputting the error:
clang++ -O3 -std=c++1z -stdlib=libc++ -Wall main.cpp
Undefined symbols for architecture x86_64:
"test::~test()", referenced from:
_main in main-df96d9.o
ld: symbol(s) not found for architecture x86_64
If you either, uncomment the line where I create the test t; object, or remove the template parameter from do_test(), it will compile.
Note that the example is simplistic, the actual software requires the custom constructor, the template parameter, etc.
Any idea why it is complaining about finding the destructor?
Aucun commentaire:
Enregistrer un commentaire