I recently ran valgrind --tool=helgrind on my project and got a warning "possible data race", which I thought was concerning. However, even this simple test program leads to this message:
#include <iostream>
#include <thread>
#include <future>
int main()
{
std::packaged_task<void()> task(
{
std::cout << "Hello\n"; // You can leave this out
});
auto future = task.get_future();
std::thread(std::move(task)).detach();
future.get();
}
Compiled with g++-4.9 -p -g -std=c++11 -pthread -O3 test.cpp, the output of valgrind --tool=helgrind ./a.out is:
==12808== Helgrind, a thread error detector
==12808== Copyright (C) 2007-2013, and GNU GPL'd, by OpenWorks LLP et al.
==12808== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==12808== Command: ./a.out
==12808==
Hello
My question: Am I safe to ignore this? If so, how to suppress these warnings?
あなたの回答
tips
プレビュー