public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/108118] std::weak_ptr lacks a self-usurp check on move
Date: Tue, 16 May 2023 12:50:06 +0000	[thread overview]
Message-ID: <bug-108118-4-i9lLpCcDvo@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108118-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:9578570e305e77b8c105583506781158c137f743

commit r11-10768-g9578570e305e77b8c105583506781158c137f743
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Dec 15 09:52:48 2022 +0000

    libstdc++: Fix self-move for std::weak_ptr [PR108118]

    I think an alternative fix would be something like:

      _M_ptr = std::exchange(rhs._M_ptr, nullptr);
      _M_refcount = std::move(rhs._M_refcount);

    The standard's move-and-swap implementation generates smaller code at
    all levels except -O0 and -Og, so it seems simplest to just do what the
    standard says.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108118
            * include/bits/shared_ptr_base.h (weak_ptr::operator=):
            Implement as move-and-swap exactly as specified in the standard.
            * testsuite/20_util/weak_ptr/cons/self_move.cc: New test.

    (cherry picked from commit 92eb0adc14a5f84acce7e5bc780b81b1544b24aa)

  parent reply	other threads:[~2023-05-16 12:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15  8:02 [Bug libstdc++/108118] New: " b.stanimirov at abv dot bg
2022-12-15  8:41 ` [Bug libstdc++/108118] " pinskia at gcc dot gnu.org
2022-12-15  8:51 ` pinskia at gcc dot gnu.org
2022-12-15  8:53 ` pinskia at gcc dot gnu.org
2022-12-15  9:33 ` redi at gcc dot gnu.org
2022-12-15  9:36 ` redi at gcc dot gnu.org
2022-12-16 14:30 ` cvs-commit at gcc dot gnu.org
2023-01-06 12:07 ` redi at gcc dot gnu.org
2023-03-28 23:35 ` cvs-commit at gcc dot gnu.org
2023-05-16 12:50 ` cvs-commit at gcc dot gnu.org [this message]
2023-05-16 15:03 ` redi at gcc dot gnu.org
2023-06-23 16:13 ` cvs-commit at gcc dot gnu.org
2023-06-23 16:19 ` 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-108118-4-i9lLpCcDvo@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).