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

--- Comment #4 from Oleg Kuznetsov <w15developer at proton dot me> ---
This appears to be an interaction bug between modules and reflection,
specifically around cross-partition entities.

Minimal reproducer (godbolt: https://godbolt.org/z/W4x6W166j):

  // partition_a.cppm
```cpp
  module;
  #include <string>
  export module A:A;
  export namespace core_types {
      using Str = std::string;
  }
```

  // module.cppm
```cpp  
  module;
  #include <meta>
  #include <string>
  export module A;
  export import :A;

  export namespace core_types_1 {
      using Str = std::string;
  }

  consteval auto Test() {
      constexpr auto ctx = std::meta::access_context::current();
      return std::meta::members_of(^^core_types_1, ctx).size();
  }

  consteval auto Test1() {
      constexpr auto ctx = std::meta::access_context::current();
      return std::meta::members_of(^^core_types, ctx).size();
  }

  static_assert(Test() >= 0);
  static_assert(Test1() >= 0);
```

Observations:
- Test() succeeds. `core_types_1` is declared directly in the primary
  module interface unit (module A)
- Test1() ICEs. `core_types` is declared in module partition `A:A`
  and only re-exported into `module A` via `export import :A;`

So the trigger is specifically: reflecting on (via std::meta::*) an
entity whose *declaration* lives in a different module partition than
the one performing the reflection, as opposed to an entity declared
directly in the current module unit. Tested with GCC 16.2

Reply via email to