|
From: Bart V. A. <bva...@ac...> - 2014-06-09 09:35:16
|
On 06/09/14 08:51, Dave Ohlsson wrote:
> int i = 0;
>
> int main()
> {
> std::thread t1( []() { i = 1; } );
> std::thread t2( []() { i = 2; } );
> t1.join();
> t2.join();
> std::cerr << "i = " << i << std::endl;
> return 0;
> }
>
> [other code as before]
> </updated part of main.cc>
>
> The problem now is that DRD does not warn about the data race.
Can you repeat this test with a sleep(1) inserted before "i = 1" ? This
false negative is maybe caused by std::thread using a shared pointer to
manage the created thread. Maybe that annotation informs DRD that i = 1
has finished before i = 2 is executed, hence the false negative.
Bart.
|