https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59950
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:cb123480984d49c6a6e81b026633fc8ffff7883e commit r11-9681-gcb123480984d49c6a6e81b026633fc8ffff7883e 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.c (build_over_call): Use cp_build_indirect_ref. gcc/testsuite/ChangeLog: * g++.dg/init/assign2.C: New test.