https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98893
--- 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:736e8eef6c0df860f9b0469f9f7cfb8c121a70a7 commit r15-7341-g736e8eef6c0df860f9b0469f9f7cfb8c121a70a7 Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Sat Feb 1 21:21:37 2025 +1100 c++: Modularise start_cleanup_fn [PR98893] 'start_cleanup_fn' is not currently viable in modules, due to generating functions relying on the 'start_cleanup_cnt' counter which is reset to 0 with each new TU. This means that cleanup functions declared in a TU will conflict with any imported cleanup functions. This patch mitigates the problem by using the mangled name of the decl we're destroying as part of the name of the function. This should avoid clashes unless the decls would have clashed anyway. PR c++/98893 gcc/cp/ChangeLog: * decl.cc (start_cleanup_fn): Make name from the mangled name of the passed-in decl. (register_dtor_fn): Pass decl to start_cleanup_fn. gcc/testsuite/ChangeLog: * g++.dg/modules/pr98893_a.H: New test. * g++.dg/modules/pr98893_b.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>