public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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: Sat, 15 Jul 2023 13:53:22 +0000 [thread overview] Message-ID: <bug-110441-4-Js4LTIY0bA@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110441-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110441 --- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:0de651db45c758f54e9ed917069795a3835499de commit r14-2539-g0de651db45c758f54e9ed917069795a3835499de Author: Patrick Palka <ppalka@redhat.com> Date: Sat Jul 15 09:50:51 2023 -0400 c++: copy elision w/ obj arg and static memfn call [PR110441] Here the call A().f() is represented as a COMPOUND_EXPR whose first operand is the otherwise unused object argument A() and second operand is the call result (both are TARGET_EXPRs). Within the return statement, this outermost COMPOUND_EXPR ends up foiling the copy elision check in build_special_member_call, resulting in us introducing a bogus call to the deleted move constructor. (Within the variable initialization, which goes through ocp_convert instead of convert_for_initialization, we've already been eliding the copy -- despite the outermost COMPOUND_EXPR -- ever since r10-7410-g72809d6fe8e085 made ocp_convert look through COMPOUND_EXPR). In contrast I noticed '(A(), A::f())' (which should be equivalent to the above call) is represented with the COMPOUND_EXPR inside the RHS's TARGET_EXPR initializer thanks to a special case in cp_build_compound_expr. So this patch fixes this by making keep_unused_object_arg use cp_build_compound_expr as well. PR c++/110441 gcc/cp/ChangeLog: * call.cc (keep_unused_object_arg): Use cp_build_compound_expr instead of building a COMPOUND_EXPR directly. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/elide8.C: New test.
next prev parent reply other threads:[~2023-07-15 13:53 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-27 18:48 [Bug c++/110441] New: c++17 deferred materialization of temporaries fails when calling class static with member syntax eric.niebler at gmail dot com 2023-06-28 12:47 ` [Bug c++/110441] c++17: temporary causes static member function call to confuse required copy elision gasper.azman at gmail dot com 2023-06-28 12:48 ` gasper.azman at gmail dot com 2023-06-28 14:27 ` ppalka at gcc dot gnu.org 2023-06-28 14:30 ` ppalka at gcc dot gnu.org 2023-06-28 15:23 ` matt.cross+gcc-bugzilla at gmail dot com 2023-07-15 13:53 ` cvs-commit at gcc dot gnu.org [this message] 2023-07-15 14:00 ` ppalka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-110441-4-Js4LTIY0bA@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).