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

--- Comment #7 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
There might be more to it as well; the following sample (reduced from a
different error) complains about conflicting declarations:

  // shared_ptr.hpp
  template <typename> struct unique_ptr {
    template <typename> friend class out_ptr_t;
  };
  template <typename> struct shared_ptr {
    template <typename> friend class out_ptr_t;
  };

  // a.cpp
  module;
  #include "shared_ptr.hpp"
  export module M;
  unique_ptr<int> s;
  export template <typename> void foo() { shared_ptr<int> u; }

  // b.cpp
  #include "shared_ptr.hpp"
  import M;
  int main() { foo<int>(); }

$ g++ -std=c++23 -fmodules -S [ab].cpp
In file included from b.cpp:1:
shared_ptr.hpp: In instantiation of ‘struct shared_ptr<int>’:
a.cpp:5:57:   required from ‘void foo@M() [with <template-parameter-1-1> =
int]’
    5 | export template <typename> void foo() { shared_ptr<int> u; }
      |                                                         ^
b.cpp:3:22:   required from here
    3 | int main() { foo<int>(); }
      |              ~~~~~~~~^~
shared_ptr.hpp:6:36: error: conflicting declaration of template
‘template<class> class out_ptr_t’
    6 |   template <typename> friend class out_ptr_t;
      |                                    ^~~~~~~~~
In file included from a.cpp:2,
of module M, imported at b.cpp:2:
shared_ptr.hpp:2:36: note: previous declaration ‘template<class> class
out_ptr_t@M’
    2 |   template <typename> friend class out_ptr_t;
      |                                    ^~~~~~~~~

Reply via email to