https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99507
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:425afe1f0c907e6469cef1672160c9c95177e71a commit r11-7645-g425afe1f0c907e6469cef1672160c9c95177e71a Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Mar 12 10:11:24 2021 +0100 c++: Fix up calls to immediate functions returning reference [PR99507] build_cxx_call calls convert_from_reference at the end, so if an immediate function returns a reference, we were constant evaluating not just that call, but that call wrapped in an INDIRECT_REF. That unfortunately means it can constant evaluate to something non-addressable, so if code later needs to take its address it will fail. The following patch fixes that by undoing the convert_from_reference wrapping for the cxx_constant_value evaluation and readdding it ad the end. 2021-03-12 Jakub Jelinek <ja...@redhat.com> PR c++/99507 * call.c (build_over_call): For immediate evaluation of functions that return references, undo convert_from_reference effects before calling cxx_constant_value and call convert_from_reference afterwards. * g++.dg/cpp2a/consteval19.C: New test.