public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hubert dot schmid at stud dot uka dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/14026] New: std::uncaught_exception is true although there are no uncaught exceptions (rethrow, ghost exception)
Date: Thu, 05 Feb 2004 10:54:00 -0000	[thread overview]
Message-ID: <20040205105427.14026.hubert.schmid@stud.uka.de> (raw)

The following code shows the problem:

#include <iostream>
int main()
{
    try {
	throw 1;
    } catch (...) {
	try {
	    throw;
	} catch (...) {
	    std::cout << std::uncaught_exception() << std::endl;
	}
    }
    std::cout << std::uncaught_exception() << std::endl;
}

The program prints:
1
1
The expected output is:
0
0

Some detail: std::uncaught_exception() uses a variable (uncaughtExceptions),
that counts the number of uncaught exceptions. The value of this variable is -1
at the two print statements. I guess, this variable is incremented each time an
exception is thrown and decremented each time an exception is caught. I also
guess, that in the above program, the variable is possible not incremented at
the rethrow statement.

-- 
           Summary: std::uncaught_exception is true although there are no
                    uncaught exceptions (rethrow, ghost exception)
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hubert dot schmid at stud dot uka dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


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


             reply	other threads:[~2004-02-05 10:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-05 10:54 hubert dot schmid at stud dot uka dot de [this message]
2004-02-05 10:59 ` [Bug c++/14026] " hubert dot schmid at stud dot uka dot de
2004-02-05 16:26 ` bangerth at dealii dot org
2004-02-05 16:40 ` [Bug libstdc++/14026] " pinskia at gcc dot gnu dot org
2004-02-05 21:53 ` pcarlini at suse dot de
2004-02-05 22:42 ` pcarlini at suse dot de
2004-02-06 14:26 ` pcarlini at suse dot de
2004-02-08 18:01 ` cvs-commit at gcc dot gnu dot org
2004-02-08 18:11 ` cvs-commit at gcc dot gnu dot org
2004-02-08 18:19 ` rth at gcc dot gnu dot org
2004-02-08 19:45 ` pinskia at gcc dot gnu dot org
2004-08-16 15:58 ` cvs-commit at gcc dot gnu dot 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=20040205105427.14026.hubert.schmid@stud.uka.de \
    --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).