public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114387] New: Explicitly declared destructor makes basic_format_context sometimes not movable
@ 2024-03-19  2:19 de34 at live dot cn
  2024-03-26 20:47 ` [Bug libstdc++/114387] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: de34 at live dot cn @ 2024-03-19  2:19 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug libstdc++/114387] Explicitly declared destructor makes basic_format_context sometimes not movable
  2024-03-19  2:19 [Bug libstdc++/114387] New: Explicitly declared destructor makes basic_format_context sometimes not movable de34 at live dot cn
@ 2024-03-26 20:47 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-26 20:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |SUSPENDED
   Last reconfirmed|                            |2024-03-26

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://cplusplus.github.io/LWG/issue4061

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-26 20:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19  2:19 [Bug libstdc++/114387] New: Explicitly declared destructor makes basic_format_context sometimes not movable de34 at live dot cn
2024-03-26 20:47 ` [Bug libstdc++/114387] " redi at gcc dot gnu.org

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).