[Bug c++/59950] [9/10/11/12 Regression] Bogus diagnostic "taking address of temporary" taking address of trivial no-op assignment to temporary with empty class

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 25 19:28:27 GMT 2022


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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:fe5cee6f62a0b229d9d51616b7490331d39b5ddd

commit r12-6862-gfe5cee6f62a0b229d9d51616b7490331d39b5ddd
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jan 24 00:01:40 2022 -0500

    c++: assignment to temporary [PR59950]

    Given build_this of a TARGET_EXPR, cp_build_fold_indirect_ref returns the
    TARGET_EXPR.  But that's the wrong value category for the result of the
    defaulted class assignment operator, which returns an lvalue, so we need to
    actually build the INDIRECT_REF.

            PR c++/59950

    gcc/cp/ChangeLog:

            * call.cc (build_over_call): Use cp_build_indirect_ref.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/assign2.C: New test.


More information about the Gcc-bugs mailing list