From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 578B9385801C; Wed, 6 Mar 2024 21:52:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 578B9385801C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709761972; bh=sX+5tMpeaAUiLHqrCkoD1dp+5R0QSbaIoZBGlCXBmXk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JXmcCmZOhIfg3EPa/ghRReT5RdxzLBF8geE3PiM+CVyhrEwcrQZbEdbVafPu6jBFQ 4v4oR8cqdOeCs6TT2XD4R1BDB8irw+bZH82KZoNgCAm82biSRwaf1fHtcmevQ5T44p /JsCc9+CYDcl/yGtUBMoVswJw7F1qxi0C4AkBDgg= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105320] Use of shared_ptr within a type exported from a module results in spurious compiler error Date: Wed, 06 Mar 2024 21:52:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on everconfirmed keywords cc bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105320 Patrick Palka 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 --- GCC doesn't ICE, but it rejects with: error: conflicting declaration of template =E2=80=98template class std::__shared_ptr=E2=80=99 note: previous declaration =E2=80=98template class std::__shared_ptr@test_supp= ort=E2=80=99 error: conflicting declaration of template =E2=80=98template class std::__weak_ptr=E2=80=99 note: previous declaration =E2=80=98template class std::__weak_ptr@test_suppor= t=E2=80=99 Reduced: $ cat 105320_a.C module; template struct _Sp_atomic; template struct shared_ptr { template friend struct _Sp_atomic; using atomic_type =3D _Sp_atomic; }; export module test_support; export template struct A { shared_ptr data; }; $ cat 105320_b.C import test_support; A 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 struct _Sp_atomic; | ^~~~~~~~ In module test_support, imported at 105320_b.C:1: 105320_a.C: In instantiation of =E2=80=98struct shared_ptr@test_support=E2=80=99: 105320_a.C:11:18: required from =E2=80=98struct A@test_support=E2=80= =99 11 | shared_ptr data; | ^~~~ 105320_b.C:3:8: required from here 3 | A a; | ^ 105320_a.C:4:33: error: conflicting declaration of template =E2=80=98templa= te struct _Sp_atomic=E2=80=99 4 | template friend struct _Sp_atomic; | ^~~~~~~~~~ 105320_a.C:2:24: note: previous declaration =E2=80=98template struct _Sp_atomic@test_support=E2=80=99 2 | template struct _Sp_atomic; | ^~~~~~~~~~=