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 c++/101442] [9/10/11/12 Regression] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO
Date: Wed, 14 Jul 2021 09:45:18 +0000	[thread overview]
Message-ID: <bug-101442-4-5eYcK0Lau6@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101442-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

bool destroyed = false;

struct A
{
    A() {}
    A(const A &) = delete;
    A &operator=(const A &) = delete;
    ~A() {destroyed = true;}
};

struct B
{
    const A &a;
    struct string {
     string(const char*) { }
    ~string() { }
    } s;
};

B foo()
{
    B ret{ A{}, "" };
    return ret;
}

int main()
{
  {
    B b = foo();
  }
  if (!destroyed)
    __builtin_abort();
}

  parent reply	other threads:[~2021-07-14  9:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 18:17 [Bug c++/101442] New: Destructor not called for a temporary object, if it iamsupermouse at mail dot ru
2021-07-13 18:19 ` [Bug c++/101442] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO iamsupermouse at mail dot ru
2021-07-14  6:09 ` rguenth at gcc dot gnu.org
2021-07-14  9:39 ` [Bug c++/101442] [9/10/11/12 Regression] " redi at gcc dot gnu.org
2021-07-14  9:44 ` redi at gcc dot gnu.org
2021-07-14  9:45 ` redi at gcc dot gnu.org [this message]
2021-07-19 11:49 ` rguenth at gcc dot gnu.org
2022-04-13 16:13 ` jason at gcc dot gnu.org
2022-04-14  0:24 ` cvs-commit at gcc dot gnu.org
2022-05-13 16:28 ` [Bug c++/101442] [9/10/11 " cvs-commit at gcc dot gnu.org
2022-05-13 17:14 ` [Bug c++/101442] [9/10 " cvs-commit at gcc dot gnu.org
2022-05-13 17:41 ` [Bug c++/101442] [9 " cvs-commit at gcc dot gnu.org
2022-05-13 17:51 ` jason 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-101442-4-5eYcK0Lau6@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).