https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116929
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:01d3a974fe3474c37cd52b595c29dddafad954dc commit r14-10825-g01d3a974fe3474c37cd52b595c29dddafad954dc Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Thu May 23 22:50:58 2024 +1000 c++/modules: Fix treatment of unnamed types [PR116929] In r14-9530 we relaxed "depending on type with no-linkage" errors for declarations that could actually be accessed from different TUs anyway. However, this also enabled it for unnamed types, which never work. In a normal module interface, an unnamed type is TU-local by [basic.link] p15.2, and so cannot be exposed or the program is ill-formed. We don't yet implement this checking but we should assume that we will later; currently supporting this actually causes ICEs when attempting to create the mangled name in some situations. For a header unit, by [module.import] p5.3 it is unspecified whether two TUs importing a header unit providing such a declaration are importing the same header unit. In this case, we would require name mangling changes to somehow allow the (anonymous) type exported by such a header unit to correspond across different TUs in the presence of other anonymous declarations, so for this patch just assume that this case would be an ODR violation instead. PR c++/116929 gcc/cp/ChangeLog: * tree.cc (no_linkage_check): Anonymous types can't be accessed in a different TU. gcc/testsuite/ChangeLog: * g++.dg/modules/linkage-1_a.C: Remove anonymous type test. * g++.dg/modules/linkage-1_b.C: Likewise. * g++.dg/modules/linkage-1_c.C: Likewise. * g++.dg/modules/linkage-2.C: Add note about anonymous types. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com> Reviewed-by: Jason Merrill <ja...@redhat.com> (cherry picked from commit 0173dcce92baa62a74929814a75edb75eeab1a54)