https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100368

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:88834c7d05acf5ce4eaccda56fb04436595e2a52

commit r12-1068-g88834c7d05acf5ce4eaccda56fb04436595e2a52
Author: Patrick Palka <ppa...@redhat.com>
Date:   Wed May 26 08:37:30 2021 -0400

    c++: constexpr and copy elision within mem init [PR100368]

    In the testcase below, the member initializer b(f()) inside C's default
    constructor is encoded as a TARGET_EXPR wrapping the CALL_EXPR f() in
    C++17 mode.  During massaging of this constexpr constructor,
    build_target_expr_with_type called from bot_manip on this initializer
    tries to add an extra copy using B's implicitly deleted copy constructor
    rather than just preserving the copy elision.

    Since it's wrong to introduce an extra copy when initializing a
    temporary from a CALL_EXPR, this patch makes build_target_expr_with_type
    avoid calling force_rvalue in this case.  Additionally, bot_manip should
    be copying TARGET_EXPRs in a more oblivious manner, so this patch makes
    bot_manip use force_target_expr instead of build_target_expr_with_type.
    And since bot_manip is now no longer a caller, we can remove the void
    initializer handling in build_target_expr_with_type.

            PR c++/100368

    gcc/cp/ChangeLog:

            * tree.c (build_target_expr_with_type): Don't call force_rvalue
            on CALL_EXPR initializer.  Simplify now that bot_manip is no
            longer a caller.
            (bot_manip): Use force_target_expr instead of
            build_target_expr_with_type.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/elide6.C: New test.

Reply via email to