https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58142
Martin Stumpf <der-martin-stumpf at web dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |der-martin-stumpf at web dot de
--- Comment #1 from Martin Stumpf <der-martin-stumpf at web dot de> ---
I can confirm that this in fact causes segfaults, which is the reason why we
had to switch to clang++ under MacOS.
Source Code: =========================
#include <thread>
#include <vector>
#include <unordered_map>
class MyClass
{
public:
MyClass(){
printf("%p\n", this);
}
~MyClass(){
printf("~%p\n", this);
}
std::unordered_map<int, int> member;
};
thread_local MyClass threadLocalObject;
int main(){
std::vector<std::thread> threads;
for (int i = 0; i < 40; ++i){
threads.emplace_back([&](){
printf("%ld\n", threadLocalObject.member.size());
});
}
for (auto &thread : threads)
thread.join();
return 0;
}
======================
Compiled with "g++-6 -std=c++11 -O0 -g" on MacOS 10.12.6, g++-6 (Homebrew GCC
6.4.0) 6.4.0.
Segfaults with:
malloc: *** error for object 0xa38333130303962: pointer being freed was not
allocated