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 <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:fe5cee6f62a0b229d9d51616b7490331d39b5ddd commit r12-6862-gfe5cee6f62a0b229d9d51616b7490331d39b5ddd Author: Jason Merrill <ja...@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.