https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125498
--- Comment #4 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:64627d4f8349af24f5a84c0936eb00256769b534 commit r17-1464-g64627d4f8349af24f5a84c0936eb00256769b534 Author: Marek Polacek <[email protected]> Date: Tue Jun 9 16:50:14 2026 -0400 c++/reflection: ICE with -g on reflection of ctor param [PR125498] Here we ICE because S::S(int) lost its DECL_ARGUMENTS, and so the skip_artificial_parms_for in FUNCTION_FIRST_USER_PARM in write_reflection crashes on a null tree. We've thrown away the body of S::S(int) in cgraph_node::release_body along with its DECL_ARGUMENTS: if (!keep_arguments) DECL_ARGUMENTS (decl) = NULL; This happens in finalize_compilation_unit -> analyze_functions because there are no cgraph_node::callers (so referred_to_p() is false I think), and .force_output is false. We then call mangle_decl from finalize_compilation_unit -> dwarf2out_early_finish. Instead of FUNCTION_FIRST_USER_PARM we can use DECL_PARM_INDEX, thus avoiding the need to either keep the body around or at least set keep_arguments. PR c++/125498 gcc/cp/ChangeLog: * mangle.cc (write_reflection): Use DECL_PARM_INDEX for computing the parameter index. gcc/testsuite/ChangeLog: * g++.dg/reflect/mangle7.C: New test. * g++.dg/reflect/parameters_of9.C: New test. Reviewed-by: Patrick Palka <[email protected]>
