https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127749
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:22b698e6c1a2f1ca0d2a9ef86697e4cc1f177dd8 commit r16-9828-g22b698e6c1a2f1ca0d2a9ef86697e4cc1f177dd8 Author: Marek Polacek <[email protected]> Date: Wed Oct 7 13:16:03 2026 -0400 c++/reflection: ICE on template tree from metafunction [PR127749] Here we are in a generic lambda and want to process a call to identifier_of. Since it's a generic lambda, the lambda's operator() is a template. eval_identifier_of calls build_special_member_call which calls build_new_method_call which, in a template, creates: call = (build_min_non_dep_call_vec (call, build_min (COMPONENT_REF, TREE_TYPE (CALL_EXPR_FN (call)), orig_instance, orig_fns, NULL_TREE), orig_args)); but that can't be evaluated by cxx_eval_constant_expression that we call after process_metafunction. (In this test, we are called from tsubst_lambda_expr -> finish_if_stmt_cond -> cxx_constant_value.) Since in process_metafunction we shouldn't encounter calls that are instantiation-dependent, a simple fix is to force a non-template context. To be sure I ran a full regtest with gcc_checking_assert (!instantiation_dependent_expression_p (call)); just before the sentinel and found no problems. PR c++/127749 gcc/cp/ChangeLog: * reflect.cc (process_metafunction): Add processing_template_decl_sentinel. gcc/testsuite/ChangeLog: * g++.dg/reflect/dep17.C: New test. Reviewed-by: Jason Merrill <[email protected]> (cherry picked from commit 4b1320d229dcbf6966aff194219eb2bbd8727801)
