https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77744
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This shows the same race, without any library components:
struct regex {
struct regex_impl { int i; int size() const { return i; } };
regex_impl* p;
regex() : p(new regex_impl{42}) { }
~regex() { delete p; }
int size() const { return p->size(); }
void f(int) const { }
};
struct regex_iterator {
regex_iterator(const regex& re) { for (int i = 0; i < re.size(); ++i)
re.f(i); }
};
int main()
{
const regex reTest;
auto f = [&reTest]()
{
regex_iterator iter(reTest);
};
#pragma omp parallel for
for(unsigned i = 0; i < 10; ++i)
f();
}