https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>: https://gcc.gnu.org/g:3471a61ed0ddef70de8f1bbba85cd1e945fc86fd commit r14-8196-g3471a61ed0ddef70de8f1bbba85cd1e945fc86fd Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Sat Dec 16 21:34:45 2023 +1100 c++: Prevent overwriting arguments when merging duplicates [PR112588] When merging duplicate instantiations of function templates, currently read_function_def overwrites the arguments with that of the existing duplicate. This is problematic, however, since this means that the PARM_DECLs in the body of the function definition no longer match with the PARM_DECLs in the argument list, which causes issues when it comes to generating RTL. There doesn't seem to be any reason to do this replacement, so this patch removes that logic. PR c++/112588 gcc/cp/ChangeLog: * module.cc (trees_in::read_function_def): Don't overwrite arguments. gcc/testsuite/ChangeLog: * g++.dg/modules/merge-16.h: New test. * g++.dg/modules/merge-16_a.C: New test. * g++.dg/modules/merge-16_b.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>