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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |nshead at gcc dot 
gnu.org
                 CC|                            |nshead at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2025-01-17

--- Comment #2 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Confirmed.  Here's a reduced testcase which doesn't rely on us not completely
discarding the GMF:

  // a.cpp
  module;
  template <typename T> struct S {
    auto foo() {}
  };
  export module A;
  template struct S<char>;

  // b.cpp
  module;
  template <typename T> struct S {
    auto foo() {}
  };
  template struct S<char>;
  export module B;
  import A;
  template <typename> void x() {
    S<char>{}.foo();
  }

  // c.cpp
  import B;

Compiling with 'g++ -fmodules -fno-module-lazy -Wno-global-module -S [abc].cpp'
gives:

In module B, imported at c.cpp:1:
b.cpp:3:8: error: conflicting global module declaration ‘auto S@A<T>::foo()
[with T = char]’
    3 |   auto foo() {}
      |        ^~~
In module A, imported at b.cpp:7,
of module B, imported at c.cpp:1:
a.cpp:3:8: note: existing declaration ‘auto S@A<T>::foo() [with T = char]’
    3 |   auto foo() {}
      |        ^~~

I think I have a fix.

Reply via email to