public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/52320] missing destructor call after thrown exception in initializer
Date: Tue, 21 Feb 2012 08:38:00 -0000	[thread overview]
Message-ID: <bug-52320-4-06f8m4wvaS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52320-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52320

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-02-21 08:26:30 UTC ---
Confirmed for 4.7.0 20120218 (experimental).

Reduced example with added information:

//----
#include <iostream>

#define FUNCTION_NAME __PRETTY_FUNCTION__

#define TRACE_FUNCTION(I) { std::cout << this << "->" << FUNCTION_NAME << "; i
= " << I << std::endl; }

struct A {
  int i;
  A(int i) : i(i) { TRACE_FUNCTION(i); }
  A(const A& rhs) : i(rhs.i) { TRACE_FUNCTION(i); }
  A &operator=(const A& rhs) { i = rhs.i; TRACE_FUNCTION(i); return *this; }
  ~A() { TRACE_FUNCTION(i); }
};

struct Y {
  A e1[2];
};

int main() {
  try {
    Y y1[1] = { {{1, (throw 0, 2)} } };
  } catch (int) {
  }
}
//----

Observed output is:

0x22fd60->A::A(int); i = 1

It does not happen when the local array y1 is replaced by a non-array Y.


  reply	other threads:[~2012-02-21  8:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21  1:03 [Bug c++/52320] New: " mmehlich at semanticdesigns dot com
2012-02-21  8:38 ` daniel.kruegler at googlemail dot com [this message]
2012-02-21 10:49 ` [Bug c++/52320] " redi at gcc dot gnu.org
2012-02-21 10:56 ` daniel.kruegler at googlemail dot com
2020-03-11  7:00 ` jakub at gcc dot gnu.org
2020-05-07 11:56 ` jakub at gcc dot gnu.org
2020-07-23  6:51 ` rguenth at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2022-01-07  0:24 ` cvs-commit at gcc dot gnu.org
2022-01-07  0:30 ` 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-52320-4-06f8m4wvaS@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).