https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121724

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |rejects-valid
                 CC|                            |nshead at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2025-08-31

--- Comment #1 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Confirmed.  With a checking build the DECL_MODULE_PURVIEW_P assertion here
fails when building foo:

      /* Namespace, walk exactly once.  */
      data->met_namespace = true;
      if (data->hash->add_namespace_entities (decl, data->partitions))
        {
          /* It contains an exported thing, so it is exported.  */
          gcc_checking_assert (DECL_MODULE_PURVIEW_P (decl));
          gcc_checking_assert (TREE_PUBLIC (decl) || header_module_p ());
          DECL_MODULE_EXPORT_P (decl) = true;
        }


foo.cc:8:8: internal compiler error: in add_binding_entity, at
cp/module.cc:14659
    8 | export module foo;
      |        ^~~~~~
0x3d0c265 internal_error(char const*, ...)
        ../../gcc/gcc/diagnostic-global-context.cc:534
0x3d1b364 fancy_abort(char const*, int, char const*)
        ../../gcc/gcc/diagnostics/context.cc:1687
0x1233e73 depset::hash::add_binding_entity(tree_node*, WMB_Flags, void*)
        ../../gcc/gcc/cp/module.cc:14659
0x1279f70 walk_module_binding(tree_node*, bitmap_head*, bool (*)(tree_node*,
WMB_Flags, void*), void*)
        ../../gcc/gcc/cp/name-lookup.cc:4314
0x1234136 depset::hash::add_namespace_entities(tree_node*, bitmap_head*)
        ../../gcc/gcc/cp/module.cc:14700
0x1233e0a depset::hash::add_binding_entity(tree_node*, WMB_Flags, void*)
        ../../gcc/gcc/cp/module.cc:14656
0x1279f70 walk_module_binding(tree_node*, bitmap_head*, bool (*)(tree_node*,
WMB_Flags, void*), void*)
        ../../gcc/gcc/cp/name-lookup.cc:4314
0x1234136 depset::hash::add_namespace_entities(tree_node*, bitmap_head*)
        ../../gcc/gcc/cp/module.cc:14700
0x1247090 module_state::write_begin(elf_out*, cpp_reader*,
module_state_config&, unsigned int&)
        ../../gcc/gcc/cp/module.cc:20249
0x124f182 finish_module_processing(cpp_reader*)
        ../../gcc/gcc/cp/module.cc:22800
0x11605ba c_parse_final_cleanups()
        ../../gcc/gcc/cp/decl2.cc:5799
0x157b062 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.cc:1426


It looks like the issue is we mark B as exported but don't correctly mark its
containing inline namespace as exported; we probably need to walk up the tree
until we reach the parent namespace and mark them all as exported (and purview)
too.

Reply via email to