public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: "Pétur Runólfsson" <peturr02@ru.is>
To: bkoz@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: RE: libstdc++/10132: filebuf destructor throws exceptions
Date: Fri, 25 Apr 2003 21:46:00 -0000	[thread overview]
Message-ID: <20030425214601.11793.qmail@sources.redhat.com> (raw)

The following reply was made to PR libstdc++/10132; it has been noted by GNATS.

From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
To: "Benjamin Kosnik" <bkoz@redhat.com>
Cc: <gcc-bugs@gcc.gnu.org>,
	<gcc-gnats@gcc.gnu.org>
Subject: RE: libstdc++/10132: filebuf destructor throws exceptions
Date: Fri, 25 Apr 2003 21:36:55 -0000

 > >Also, what's the rationale behind rethrowing some but not all
 > >exceptions?
 >=20
 > Why would you propogate when the the exception can be cleaned=20
 > up at the
 > point of failure? If something that this function is not prepared to
 > deal with happens, then it can rethrow.
 
 I don't see that filebuf members can in general handle exceptions
 thrown by codecvt members. The best they can reasonably do is to
 catch the exception and return an error value.
 
 > >I don't think that basic_filebuf should catch exceptions thrown
 > >by use_facet or codecvt members.=20
 >=20
 > Why?
 
 1. Consistency with the rest of the library, which allows
    exceptions to propagate.
 
 2. basic_istream and basic_ostream allow the caller to decide
    on the exception handling policy.
 
 3. When codecvt operations throw exceptions the filebuf is in
    general unreadable and left in an indeterminate state. This
    indicates that badbit should be set in rdstate(). For
    underflow(), this will only happen if an exception is
    thrown.
 
 > 1) make non-virtual codecvt MF's throw(), wrap all virtual calls with
 > try, and in the catch block return codecvt_base::error.
 
 I don't like this. It decides the exception handling policy for all
 users of codecvt, not just filebuf.
 
 > 2) try/catch in filebuf::~filebuf. The problem with this is that the
 > "cleanups" are quite difficult to do in ~filebuf if filebuf::close
 > fails, and we will end up either duplicating a bunch of filbuf::close,
 > or leaking memory.
 
 If filebuf::close() frees all resources, even when exceptions are
 thrown, ~filebuf won't have to do any cleanup.
 
 > 3) try to deal with the codecvt errors at the point of usage, ie in
 > underflow/overflow. I think this makes the most sense.
 
 If codecvt::in throws an exception, underflow can't produce any
 characters and hence must fail, so I don't see that this is
 possible.
 
 Petur


             reply	other threads:[~2003-04-25 21:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-25 21:46 Pétur Runólfsson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-04-28 16:00 bkoz
2003-04-25 21:56 Pétur Runólfsson
2003-04-25  0:56 Benjamin Kosnik
2003-04-24 22:26 Benjamin Kosnik
2003-04-24 22:06 Benjamin Kosnik
2003-04-24 18:56 Pétur Runólfsson
2003-04-24  6:06 Benjamin Kosnik
2003-04-24  6:06 Benjamin Kosnik
2003-04-23  8:56 Pétur Runólfsson
2003-04-23  3:47 bkoz
2003-04-22  1:08 bkoz
2003-03-18 12:16 peturr02

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=20030425214601.11793.qmail@sources.redhat.com \
    --to=peturr02@ru.is \
    --cc=bkoz@gcc.gnu.org \
    --cc=gcc-prs@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).