https://bugs.llvm.org/show_bug.cgi?id=41769

            Bug ID: 41769
           Summary: Thread Sanitizer causes false positive on a static
                    array
           Product: compiler-rt
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedb...@nondot.org
          Reporter: vincent.lebour...@starqube.com
                CC: llvm-bugs@lists.llvm.org

The following code causes a false data race detection.
~~~
#include <array>
#include <thread>
#include <vector>

class String{
public:
        std::array<unsigned char,16>value;
        String(const
char(&s)[2])noexcept:value(){std::memcpy(value.data(),s,1);}
};

void createStaticAndFind(){
        static const std::array<String,3>a={"1","2","3"};
        if(a[2].value==String("3").value){}}

int main(){
        std::vector<std::thread>threads;
        for(size_t i=0;i<100;++i){
                threads.emplace_back(createStaticAndFind);}
        return 0;}
~~~

Compiled and linked with -L/usr/local/lib and -fsanitize=thread.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to