From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B5D15389682D; Mon, 7 Dec 2020 11:57:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5D15389682D From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59238] Dynamic allocating a list-initialized object of a type with private destructor fails. Date: Mon, 07 Dec 2020 11:57:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cc Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Dec 2020 11:57:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D59238 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- I guess the difference is that when type_build_ctor_call (type) is true, we explicitly say we don't want cleanups: if (type_build_ctor_call (type) && !explicit_value_init_p) { init_expr =3D build_special_member_call (init_expr, complete_ctor_identifi= er, init, elt_type, LOOKUP_NORMAL, complain|tf_no_cleanup= ); } then the explicit_value_init_p doesn't either: else if (explicit_value_init_p) { /* Something like `new int()'. NO_CLEANUP is needed so we don't try and build a (possibly ill-formed) destructor. */ tree val =3D build_value_init (type, complain | tf_no_cleanup= ); if (val =3D=3D error_mark_node) return error_mark_node; init_expr =3D build2 (INIT_EXPR, type, init_expr, val); } but the ie =3D build_x_compound_expr_from_vec (*init, "new initializer", complain); init_expr =3D cp_build_modify_expr (input_location, init_expr, INIT_EXPR, ie, complain); case doesn't do that. Adding | tf_no_cleanup to those 3 cases seems to fix this, testing it with = make check-c++-all now.=