This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/68338] New: tsan report error about c++11 static local initialize
- From: "dushistov at mail dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 13 Nov 2015 16:45:50 +0000
- Subject: [Bug sanitizer/68338] New: tsan report error about c++11 static local initialize
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68338
Bug ID: 68338
Summary: tsan report error about c++11 static local initialize
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: dushistov at mail dot ru
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
Target Milestone: ---
With code like this:
#include <thread>
#include <iostream>
#include <string>
std::string message()
{
static std::string msg("hi");
return msg;
}
int main()
{
std::thread t1([]() { std::cout << message() << "\n"; });
std::thread t2([]() { std::cout << message() << "\n"; });
t1.join();
t2.join();
}
compile like this:
g++ -O3 -g3 -fsanitize=thread -Wall -std=c++11 -pthread -Wextra test.cpp
according to c++11 statnadard such code should be thread safe,
at the same time if replate g++(gcc 5.2) by clang++(clang 3.7)
it does run without any reported failures.