https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99274
--- 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:a96c774f7bb99729ab9e7e2a57cd970469ccbc08 commit r15-4944-ga96c774f7bb99729ab9e7e2a57cd970469ccbc08 Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Mon Aug 12 10:57:39 2024 +1000 c++/modules: Merge default arguments [PR99274] When merging a newly imported declaration with an existing declaration we don't currently propagate new default arguments, which causes issues when modularising header units. This patch adds logic to propagate default arguments to existing declarations on import, and error if the defaults do not match. PR c++/99274 gcc/cp/ChangeLog: * module.cc (trees_in::is_matching_decl): Merge default arguments. * tree.cc (cp_tree_equal) <AGGR_INIT_EXPR>: Handle unification of AGGR_INIT_EXPRs with new VAR_DECL slots. gcc/testsuite/ChangeLog: * g++.dg/modules/lambda-7.h: Skip ODR-violating declaration when testing ODR deduplication. * g++.dg/modules/lambda-7_b.C: Note we're testing ODR deduplication. * g++.dg/modules/default-arg-1_a.H: New test. * g++.dg/modules/default-arg-1_b.C: New test. * g++.dg/modules/default-arg-2_a.H: New test. * g++.dg/modules/default-arg-2_b.C: New test. * g++.dg/modules/default-arg-3.h: New test. * g++.dg/modules/default-arg-3_a.H: New test. * g++.dg/modules/default-arg-3_b.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com> Reviewed-by: Patrick Palka <ppa...@redhat.com> Reviewed-by: Jason Merrill <ja...@redhat.com>