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

            Bug ID: 119863
           Summary: [modules] Bogus conflicting friend template
                    declaration
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pilarlatiesa at gmail dot com
  Target Milestone: ---

$ cat Test.cpp 

export module m;

template<typename>
class T;

template<typename>
class U
{
  template<typename>
  friend class T;
};

template<typename V>
class T
{
  U<V> x = {};
};

export
template<typename V>
T<V> f(V) { return {}; }

$ cat main.cpp 

import m;

int main()
{
  auto const x = f(1);
}

$ ~/gcc-15/bin/g++ -fmodules -c Test.cpp -fmodule-only

$ ~/gcc-15/bin/g++ -fmodules main.cpp 
In module m, imported at main.cpp:2:
Test.cpp: In instantiation of ‘class U@m<int>’:
Test.cpp:17:8:   required from ‘class T@m<int>’
   17 |   U<V> x = {};
      |        ^
main.cpp:6:19:   required from here
    6 |   auto const x = f(1);
      |                  ~^~~
Test.cpp:11:16: error: conflicting declaration of template ‘template<class>
class T@m’
   11 |   friend class T;
      |                ^
Test.cpp:5:7: nota: previous declaration ‘template<class> class T@m’
    5 | class T;
      |       ^

$ ~/gcc-15/bin/g++ -v
Usando especificaciones internas.
COLLECT_GCC=/home/pililatiesa/gcc-15/bin/g++
COLLECT_LTO_WRAPPER=/home/pililatiesa/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper
Objetivo: x86_64-pc-linux-gnu
Configurado con: ../gcc-15.1.0-RC-20250418/configure --disable-multilib
--disable-bootstrap --enable-languages=c,c++ --prefix=/home/pililatiesa/gcc-15/
Modelo de hilos: posix
Algoritmos de compresión LTO admitidos: zlib zstd
gcc versión 15.0.1 20250418 (prerelease) (GCC)

Reply via email to