https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108180
Bug ID: 108180 Summary: [OpenMP] Passing a class member variable to firstprivate() erroneously calls its dtor Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: i...@ebner-markus.de Target Milestone: --- Created attachment 54128 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54128&action=edit Minimal example cpp Following situation: I have a class. This class has a member variable (itself of a complex type). The class also has a member function in which an OpenMP loop (#pragma omp parallel for) is used. This loop accesses the mentioned class member variable through the firstprivate() flag. As far as I understood, this should copy the variable into every worker thread by calling the copy constructor. However, now upon leaving the class's member function, the dtor of the class member variable is called. Here is a code example: https://godbolt.org/z/oxb3Pq9he The log shows, that the dtor of the mentioned class member variable is erroneously called twice.