This program:
#include <iostream>
struct Foo {
Foo() {
std::cout << "Foo()\n";
}
~Foo() {
std::cout << "~Foo()\n";
}
};
struct Bar {
Bar() {
std::cout << "Bar()\n";
}
~Bar() {
std::cout << "~Bar()\n";
thread_local Foo foo;
}
};
Bar bar;
int main() {
return 0;
}
Prints
Bar()
~Bar()
Foo()
for me (GCC 6.1, Linux, x86-64). ~Foo() is never called. Is that the expected behaviour?
Aucun commentaire:
Enregistrer un commentaire