0

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.

Jayesh Badwaik
  • 101
  • 2
  • 3
  • Possible duplicate of [Can I use Thread Sanitizer for OpenMP programs?](https://stackoverflow.com/questions/33004809/can-i-use-thread-sanitizer-for-openmp-programs). Your code is perfectly fine. – Zulan Feb 16 '18 at 12:47
  • Does that statement hold even after [this bugfix](https://reviews.llvm.org/D13072)? – Jayesh Badwaik Feb 16 '18 at 12:53
  • Well I guess you could consider it a different question. While I appreciate your cloneable-[mcve]. It is important to include the necessary specification (compiler, compilation line, compiler version, how you installed the compiler) and most importantly the error itself in your question. Nevertheless I suspect the answer is still the same. – Zulan Feb 16 '18 at 18:24

0 Answers0