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++/33799] Return value's destructor not executed when a local variable's destructor throws
Date: Mon, 20 Apr 2020 09:24:16 +0000	[thread overview]
Message-ID: <bug-33799-4-WFVo2qHNMu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-33799-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reopening. Modified version of g++.dg/eh/return1.C showing the remaining bug,
in the new i() function:

// PR c++/33799
// { dg-do run }

extern "C" void abort();

int c, d;

#if __cplusplus >= 201103L
#define THROWS noexcept(false)
#else
#define THROWS
#endif

struct X
{
  X(bool throws) : throws_(throws) { ++c; }
  X(const X& x) : throws_(x.throws_) { ++c; }
  ~X() THROWS
  {
    ++d;
    if (throws_) { throw 1; }
  }
private:
  bool throws_;
};

X f()
{
  X x(true);
  return X(false);
}

X g()
{
  return X(true),X(false);
}

void h()
{
#if __cplusplus >= 201103L
  []{ return X(true),X(false); }();
#endif
}

X i()
{
  try {
    X x(true);
    return X(false);
  } catch(...) {}
  return X(false);
}

int main()
{
  try { f(); }
  catch (...) {}

  try { g(); }
  catch (...) {}

  try { h(); }
  catch (...) {}

  try { i(); }
  catch (...) {}

  if (c != d)
    throw;
}

  parent reply	other threads:[~2020-04-20  9:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-33799-4@http.gcc.gnu.org/bugzilla/>
2013-11-28 11:18 ` redi at gcc dot gnu.org
2013-11-28 12:15 ` temporal at gmail dot com
2020-04-20  3:30 ` mm-nospam at outlook dot co.nz
2020-04-20  9:24 ` redi at gcc dot gnu.org [this message]
2020-05-07 11:56 ` jakub at gcc dot gnu.org
2020-07-23  6:52 ` rguenth at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2022-01-06 14:31 ` jason at gcc dot gnu.org
2022-01-07  0:26 ` cvs-commit at gcc dot gnu.org
2022-02-01 22:51 ` jason at gcc dot gnu.org
2023-06-07  1:33 ` cvs-commit at gcc dot gnu.org
2023-11-02 20:01 ` cvs-commit at gcc dot gnu.org
2023-11-17  0:21 ` cvs-commit at gcc dot gnu.org
2023-11-17  0:21 ` cvs-commit at gcc dot gnu.org
2023-11-17  0:21 ` cvs-commit at gcc dot gnu.org
2023-11-17  0:21 ` cvs-commit at gcc dot gnu.org
2023-12-20 17:31 ` cvs-commit at gcc dot gnu.org
2024-01-24 19:39 ` cvs-commit at gcc dot gnu.org
2024-01-24 19:40 ` cvs-commit at gcc dot gnu.org
2007-10-17 11:31 [Bug c++/33799] New: " bitti at iki dot fi
2007-10-17 12:03 ` [Bug c++/33799] " rguenth at gcc dot gnu dot org
2007-10-17 12:21 ` bitti at iki dot fi
2007-10-17 17:07 ` jason at gcc dot gnu dot org
2008-09-19 12:14 ` bitti at iki dot fi

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-33799-4-WFVo2qHNMu@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).