https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80045
Bug ID: 80045 Summary: [cilkplus] The destruction of the temporary variable is not in the child Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ryxi at stu dot xidian.edu.cn Target Milestone: --- The cilkplus spec <https://www.cilkplus.org/sites/default/files/open_specifications/Intel_Cilk_plus_lang_spec_1.2.htm> said: [3.6] bullet [4]: > Any unnamed temporary variables created prior to the spawn point are > not destroyed until after the spawn point (i.e., their destructors are > invoked in the child). However currently GCC produces code that destroy the temporary in the parent. Then following code fails with random SIGSEGVs: ~~~ #include <vector> #include <cilk/cilk.h> void walk(std::vector<int> v, unsigned size) { if (v.size() < size) for (int i=0; i<8; i++) { std::vector<int> vnew(v); vnew.push_back(i); cilk_spawn walk(vnew, size); } } int main(int argc, char **argv) { std::vector<int> v{}; walk(v, 5); } ~~~ While the thread sanitizer reports many data races about destroying temporaries.