public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin von Loewis <loewis@informatik.hu-berlin.de>
To: <rysio@rumcajs.chemie.uni-halle.de>
Cc: egcs-bugs@cygnus.com, egcs@cygnus.com
Subject: Re: Troubles with exception specification
Date: Thu, 05 Nov 1998 05:10:00 -0000	[thread overview]
Message-ID: <199811050926.KAA09474@pandora> (raw)
In-Reply-To: <Pine.LNX.3.96.980922104403.5699A-100000@rumcajs.chemie.uni-halle.de>

>> 2. The call of B::func should throw `bad_exception', but it doesn't!

Thanks for your bug report. After closer inspection, and several
discussions, this is what I found:

In section 14.6.3 of "The C++ programming language", Stroustrup
explains that adding bad_exception to the exception specification will
activate the "exception mapping", which means that exceptions not
listed in the specification will be mapped to bad_exception by the
implementation.

In section 15.5.2 of the C++ Standard, paragraph 2 explains that such
mapping is performed only if unexpected throws or rethrows, which it
doesn't do by default (18.6.6.2).

Mr Stroustrup confirms that this is a contradiction between his book
and the adopted standard. He maintains that the standard should have
specified such exception mapping, and has brought this issue before
the standards committee
( http://www.research.att.com/~bs/3rd_issues.html ).

egcs currently implements the standards behaviour and not Stroustrup's
description. I'd propose that this is remains unchanged until a
decision is made by ISO.

Please note that you can work-around this discrepancy. Just define an
unexpected_handler:

#include <exception>

void my_unexpected()
{
  throw std::bad_exception();
}

int main()
{
  std::set_unexpected(my_unexpected);
  //more code
}

Hope this helps,
Martin

P.S. Even though this came up the first time, I propose to add it to
the FAQ ("Why does bad_exception not work?") or as a non-bug to the
"Known bugs list".

  reply	other threads:[~1998-11-05  5:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-22  5:33 Ryszard Kabatek
1998-11-05  5:10 ` Martin von Loewis [this message]
1998-11-06  4:27   ` FAQ vs Known Bugs List vs .texi Docs Gerald Pfeifer

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=199811050926.KAA09474@pandora \
    --to=loewis@informatik.hu-berlin.de \
    --cc=egcs-bugs@cygnus.com \
    --cc=egcs@cygnus.com \
    --cc=rysio@rumcajs.chemie.uni-halle.de \
    /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).