https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124477
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <[email protected]>: https://gcc.gnu.org/g:abf92b5506f14ce5df48349075aaae0114c5245c commit r16-8434-gabf92b5506f14ce5df48349075aaae0114c5245c Author: Nathaniel Shead <[email protected]> Date: Sun Mar 15 01:58:41 2026 +1100 c++/modules: Propagate DECL_ARGUMENTS when reading a function def [PR124477] The crash in the given PR occurs because we've streamed the definition of an anticipated builtin, but when processing the nonnull attribute we find that its DECL_ARGUMENTS is null. Back in r14-8196-g3471a61ed0ddef70de8f1bbba85cd1e945fc86fd I removed the setting of DECL_ARGUMENTS as this was causing issues where we were replacing the argument list for existing definitions. This was because the definition we streamed was referencing those same PARM_DECLs, and if they diverged we got different parts of the body with different pointers to the same logical parameter. In most cases we do not need to adjust DECL_ARGUMENTS because fn_parms_fini will substitute in the correct DECL_ARGUMENTS from the existing declaration. But if DECL_ARGUMENTS was not set on the existing declaration at all, as happens with e.g. anticipated builtins, then we do need to set them. PR c++/124477 gcc/cp/ChangeLog: * module.cc (trees_in::read_function_def): Set DECL_ARGUMENTS if installing and otherwise missing. gcc/testsuite/ChangeLog: * g++.dg/modules/builtin-10_a.C: New test. * g++.dg/modules/builtin-10_b.C: New test. Signed-off-by: Nathaniel Shead <[email protected]> Reviewed-by: Jason Merrill <[email protected]>
