From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CD3EE3858D1E; Mon, 19 Dec 2022 17:41:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD3EE3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671471675; bh=kxZ2st76dqq2L3EI6vYxXwpxffD/Hcw/r1v2t1jNm1A=; h=From:To:Subject:Date:From; b=nrbTAT35Kxd9TVnkG/XvSOJ8pEU5UGQh5hCsPwYzuVQmdF5A8y3f0kqbdvA9VoZU8 PKtoav0I7Do75iP0sZ960yAjWFOizCa/dPoFVdEgoVUzSV6i9j4RnWA/8GaFoe/fNV 3ZFIjKmX03BgesJP8zAY3utQu6C4H1gbkhlQ3qgg= From: "info@ebner-markus.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108180] New: [OpenMP] Passing a class member variable to firstprivate() erroneously calls its dtor Date: Mon, 19 Dec 2022 17:41:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: info@ebner-markus.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108180 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: info@ebner-markus.de Target Milestone: --- Created attachment 54128 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54128&action=3Dedit 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 variab= le through the firstprivate() flag. As far as I understood, this should copy the variable into every worker thr= ead 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.=