public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ppalka at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-105320-4-dlroCBtE3Z@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-105320-4@http.gcc.gnu.org/bugzilla/> 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; | ^~~~~~~~~~
next prev parent reply other threads:[~2024-03-06 21:52 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-20 18:28 [Bug c++/105320] New: " john at johnmaddock dot co.uk 2024-03-06 21:52 ` ppalka at gcc dot gnu.org [this message] 2024-03-06 21:53 ` [Bug c++/105320] " ppalka at gcc dot gnu.org 2024-03-06 22:04 ` ppalka at gcc dot gnu.org 2024-04-30 6:23 ` cvs-commit at gcc dot gnu.org 2024-04-30 7:32 ` nshead at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105320-4-dlroCBtE3Z@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).