I have a program here which fails when run with thread sanitizer and I have no idea why. Does thread sanitizer not support this case (in which case the error is a false positive?)? Or is this is a bug in the program? If it is a bug, why is it a bug? The code listing is also shown below.
#include <vector>
class A{
std::vector<int> a_;
public:
A()
{
a_ = std::vector<int>{1,2,3,4};
}
auto const& a() const { return a_;}
};
int main()
{
std::vector<A> list(100);
std::vector<std::vector<int>> g(100);
#pragma omp parallel for
for(std::size_t i=0; i < 100; ++i){
g[i] = list[i].a();
}
}
This is not a duplicate because of this bugfix.