From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CE7203858D39; Wed, 28 Jun 2023 14:27:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE7203858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687962444; bh=VJIjq1BElbdmWO49F9Pe7e9V061fk5R6aM5McUidnuI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j9EBaAQYbOVBgjfL80ZGxSIEFSR8qREAZd/2cHsMipdcXB7VrGESQNwAcyo+2FC6W wQFJVCy42leRwn3TVQ0LeKa5DEIHkW8Kwg1JMFT5+6PR2A/iw23UQKoXTQSZQSDRQm iSEqRX7+kH6oYhooFKaA56GukdRGDQx/CfANN/ls= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110441] c++17: temporary causes static member function call to confuse required copy elision Date: Wed, 28 Jun 2023 14:27:21 +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: 14.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka 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: everconfirmed bug_status cf_reconfirmed_on 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110441 Patrick Palka changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2023-06-28 CC| |jason at gcc dot gnu.org, | |ppalka at gcc dot gnu.org --- Comment #3 from Patrick Palka --- Confirmed, this never worked. The problem seems to be that because f is static, 'S().f()' is represented as a COMPOUND_EXPR that evaluates the otherwise unused object argument S() followed by a TARGET_EXPR for S::f(). = And this COMPOUND_EXPR foils the copy elision check in build_special_member_call which looks only for an outermost TARGET_EXPR and doesn't look through COMPOUND_EXPR. In contrast, '(S(), S::f())' (which should be equivalent) is represented as= a TARGET_EXPR of a COMPOUND_EXPR rather than a COMPOUND_EXPR of a TARGET_EXPR, and so copy elision is correctly avoided. So perhaps we could make keep_unused_object_arg for a TARGET_EXPR result place the COMPOUND_EXPR ins= ide the TARGET_EXPR_INITIAL instead of around the TARGET_EXPR?=