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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2026-01-16
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |nshead at gcc dot gnu.org

--- Comment #1 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Confirmed.  Reduced:

  // a.cpp
  export module repro:part;
  auto fn() {
    struct S {} s;
    return s;
  }

  // b.cpp
  export module repro;
  export import :part;

The issue is that when producing the unified CMI for 'repro', because the
(local) type 'S' is exposed we need to key it within the function definition
'fn'.  But we don't emit function bodies for non-inline functions from module
partitions, which means that 'key_local_type' crashes when trying to walk the
block declarations of 'fn'.

A workaround for now is to mark 'fn' as 'inline' so that we expose the
definitions and can key to it.

I wonder if maybe in this case we should override the merge-kind for this
declaration and just mark it as MK_unique; such a (non-vague linkage) function
definition can only be provided in one module TU to begin with, and so all
importers should be able to reference it from there.

Reply via email to