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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-03-06
     Ever confirmed|0                           |1
           Keywords|                            |rejects-valid
                 CC|                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
GCC doesn't ICE, but it rejects with:

error: conflicting declaration of template ‘template<class _Tp1,
__gnu_cxx::_Lock_policy@test_support _Lp1> class std::__shared_ptr’
note: previous declaration ‘template<class _Tp,
__gnu_cxx::_Lock_policy@test_support _Lp> class std::__shared_ptr@test_support’
error: conflicting declaration of template ‘template<class _Tp1,
__gnu_cxx::_Lock_policy@test_support _Lp1> class std::__weak_ptr’
note: previous declaration ‘template<class _Tp,
__gnu_cxx::_Lock_policy@test_support _Lp> class std::__weak_ptr@test_support’

Reduced:

$ cat 105320_a.C
module;
template<class> struct _Sp_atomic;
template<class> struct shared_ptr {
  template<class> friend struct _Sp_atomic;
  using atomic_type = _Sp_atomic<int>;
};
export module test_support;
export
template<class T> struct A {
   shared_ptr<T> data;
};

$ cat 105320_b.C
import test_support;
A<int> a;

$ g++ -fmodules-ts 105320_{a,b}.C
105320_a.C:2:1: warning: global module fragment contents must be from
preprocessor inclusion [-Wglobal-module]
    2 | template<class> struct _Sp_atomic;
      | ^~~~~~~~
In module test_support, imported at 105320_b.C:1:
105320_a.C: In instantiation of ‘struct shared_ptr@test_support<int>’:
105320_a.C:11:18:   required from ‘struct A@test_support<int>’
   11 |    shared_ptr<T> data;
      |                  ^~~~
105320_b.C:3:8:   required from here
    3 | A<int> a;
      |        ^
105320_a.C:4:33: error: conflicting declaration of template ‘template<class>
struct _Sp_atomic’
    4 |   template<class> friend struct _Sp_atomic;
      |                                 ^~~~~~~~~~
105320_a.C:2:24: note: previous declaration ‘template<class> struct
_Sp_atomic@test_support’
    2 | template<class> struct _Sp_atomic;
      |                        ^~~~~~~~~~

Reply via email to