public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/99417] [C++17] std::variant assignment fails to compile
Date: Tue, 16 May 2023 10:08:42 +0000	[thread overview]
Message-ID: <bug-99417-4-QRX1bql7EY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99417-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED
            Version|unknown                     |11.0
   Target Milestone|---                         |12.3

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't think this was a bug, at least not when you reported this. It was the
required behaviour prior to https://wg21.link/lwg3585

In the C++17 and C++20 standards variant<C>::operator=(const Original&) is
specified as:

(13.1) — If *this holds a Tj, assigns std::forward<T>(t) to the value contained
in *this.

(13.2) — Otherwise, if is_nothrow_constructible_v<Tj, T> ||
!is_nothrow_move_constructible_v<Tj> is true, equivalent to
emplace<j>(std::forward<T>(t)).

(13.3) — Otherwise, equivalent to operator=(variant(std::forward<T>(t))).


The second bullet is why the 'noexcept' on the move ctor matters, and it means
that we use the third bullet, but that won't compile because variant<C> is not
move assignable, because C is not move assignable.

So libc++ and MSVC were non-conforming in accepting this.

LWG 3585 changed the third bullet so that move assignment isn't needed. That
was implemented for libstdc++ by r13-5661-g1395415fdc2d60 and
r12-9450-ga5a03ea09ddf09.

      reply	other threads:[~2023-05-16 10:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 17:12 [Bug libstdc++/99417] New: " arthur.j.odwyer at gmail dot com
2023-05-16 10:08 ` redi at gcc dot gnu.org [this message]

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-99417-4-QRX1bql7EY@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: link
Be 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).