public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114387] New: Explicitly declared destructor makes basic_format_context sometimes not movable Date: Tue, 19 Mar 2024 02:19:08 +0000 [thread overview] Message-ID: <bug-114387-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114387 Bug ID: 114387 Summary: Explicitly declared destructor makes basic_format_context sometimes not movable Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- The following code snippet doesn't compile when using libstdc++ (https://godbolt.org/z/x3v44PTbq). ``` #include <cstddef> #include <concepts> #include <iterator> #include <format> template<class CharT> class sealed_output_iterator { private: CharT* p_; public: using difference_type = std::ptrdiff_t; explicit sealed_output_iterator(CharT* p) noexcept : p_{p} {} sealed_output_iterator(sealed_output_iterator&&) = default; sealed_output_iterator& operator=(sealed_output_iterator&&) = default; CharT& operator*() const noexcept { return *p_; } sealed_output_iterator& operator++() noexcept { ++p_; return *this; } sealed_output_iterator& operator++(int) noexcept { ++p_; return *this; } }; static_assert(std::movable<sealed_output_iterator<char>>); static_assert(!std::copyable<sealed_output_iterator<char>>); static_assert(std::output_iterator<sealed_output_iterator<char>, const char&>); static_assert(std::movable<std::basic_format_context<sealed_output_iterator<char>, char>>); // ! ```' The reason seems to be that the explicitly declared destructor suppresses the implict declaration of move constructor and assignment operator. https://github.com/gcc-mirror/gcc/blob/c4845edfeaf44756ad9672e8d143f1c8f5c4c0f6/libstdc%2B%2B-v3/include/std/format#L3839 Per https://eel.is/c++draft/format.context, it seems that no specialization member functions of basic_format_context is suppressed, so perhaps libstdc++ should remove the explicit declaration of the destructor. However, it's unclear to me whether users are supposed to be able to default-construct/copy/move basic_format_context objects. So it may be wanted to delete copy functions, but this may need an LWG issues.
next reply other threads:[~2024-03-19 2:19 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-19 2:19 de34 at live dot cn [this message] 2024-03-26 20:47 ` [Bug libstdc++/114387] " redi 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-114387-4@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).