This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Local variables in C++ and thread safety
- From: ÐÐÐÐÑÐÐÐÑÐÐ ÐÐÑÑ <alexandrov at dio dot ru>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 01 Aug 2013 15:01:55 +0400
- Subject: Local variables in C++ and thread safety
Hello.
Are automatic variables (that are defined in functions, lambdas, blocks)
in C++11 thread local? Is the following code correct:
auto f1 = [&](const double x) {
double y = sin(x);
SomeClass1 obj1;
double z = obj1.f2(y);
return cos(z);
}
// Some function which creates several threads which call f1.
calculate_parallel(f1);
Kind regards, Petr.