https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118513
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:20a4306793e4978dfff13ca669739eb46915d4e4 commit r15-7026-g20a4306793e4978dfff13ca669739eb46915d4e4 Author: Jakub Jelinek <ja...@redhat.com> Date: Sat Jan 18 21:50:23 2025 +0100 c++: Copy over further 2 flags for !TREE_PUBLIC in copy_linkage [PR118513] The following testcase ICEs in import_export_decl. When cp_finish_decomp handles std::tuple* using structural binding, it calls copy_linkage to copy various VAR_DECL flags from the structured binding base to the individual sb variables. In this case the base variable is in anonymous union, so we call constrain_visibility (..., VISIBILITY_ANON, ...) on it which e.g. clears TREE_PUBLIC etc. (flags which copy_linkage copies) but doesn't copy over DECL_INTERFACE_KNOWN/DECL_NOT_REALLY_EXTERN. When cp_finish_decl calls determine_visibility on the individual sb variables, those have !TREE_PUBLIC since copy_linkage and so nothing tries to determine visibility and nothing sets DECL_INTERFACE_KNOWN and DECL_NOT_REALLY_EXTERN. Now, this isn't a big deal without modules, the individual variables are var_finalized_p and so nothing really cares about missing DECL_INTERFACE_KNOWN. But in the module case the variables are streamed out and in and care about those bits. The following patch is an attempt to copy over also those flags (but I've limited it to the !TREE_PUBLIC case just in case). Other option would be to call it unconditionally, or call constrain_visibility with VISIBILITY_ANON for !TREE_PUBLIC (but are all !TREE_PUBLIC constrained visibility) or do it only in the cp_finish_decomp case after the copy_linkage call there. 2025-01-18 Jakub Jelinek <ja...@redhat.com> PR c++/118513 * decl2.cc (copy_linkage): If not TREE_PUBLIC, also set DECL_INTERFACE_KNOWN, assert it was set on decl and copy DECL_NOT_REALLY_EXTERN flags. * g++.dg/modules/decomp-3_a.H: New test. * g++.dg/modules/decomp-3_b.C: New test.