public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ai.azuma at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/61643] New: [C++11] std::uncaught_exception returns wrong values after std::rethrow_if_nested
Date: Sun, 29 Jun 2014 05:55:00 -0000	[thread overview]
Message-ID: <bug-61643-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 61643
           Summary: [C++11] std::uncaught_exception returns wrong values
                    after std::rethrow_if_nested
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ai.azuma at gmail dot com

The following program should terminate successfully.

//=========================================================
#include <stdexcept>
#include <exception>
#include <cstdlib>

struct X
{
  ~X() {
    if (!std::uncaught_exception()) std::abort();    // (A)
  }
};

int main() {
  try {
    throw std::runtime_error("");
  }
  catch (...) {
    try {
      std::throw_with_nested(std::runtime_error(""));
    }
    catch (std::runtime_error const &e) {
      try {
        X x;
        std::rethrow_if_nested(e);
      }
      catch (std::runtime_error const &e) {
        if (std::uncaught_exception()) std::abort(); // (B)
      }
    }
  }
  return EXIT_SUCCESS;
}
//=========================================================

However, the program is aborted at the line marked with `(A)', and at the line
marked with `(B)' if the line marked with `(A)' is commented out.

This problem is reproduced with 4.10.0 20140622, 4.9.1 20140625 and 4.8.4
20140619. The reproducer requires -std=c++11 flag to compile.


             reply	other threads:[~2014-06-29  5:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-29  5:55 ai.azuma at gmail dot com [this message]
2014-10-07  9:01 ` [Bug libstdc++/61643] " ai.azuma at gmail dot com
2014-10-07  9:02 ` ai.azuma at gmail dot com

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