https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125764
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:ea80d5b13dd9c4fdf979234ae24d5d9559402135 commit r17-1630-gea80d5b13dd9c4fdf979234ae24d5d9559402135 Author: Marek Polacek <[email protected]> Date: Fri Jun 12 09:43:52 2026 -0400 c++/reflection: crash with can_substitute and fn returning ref [PR125764] Here we crash in convert_from_reference because it gets a FUNCTION_TYPE int&(). Since its return type is a reference, it passes the c_f_r check: if (TREE_TYPE (val) && TYPE_REF_P (TREE_TYPE (val))) and we crash inside that block. The call isn't needed since r17-1271: return convert_nontype_argument (type, convert_from_reference (arg), complain); but we can also avoid calling it on TYPE_P because the function is meant for expressions only. PR c++/125764 gcc/cp/ChangeLog: * reflect.cc (eval_can_substitute): Don't call convert_from_reference on types. gcc/testsuite/ChangeLog: * g++.dg/reflect/can_substitute3.C: New test. Reviewed-by: Patrick Palka <[email protected]>
