Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #12158

Re: C++ standard library and exceptions

From ittium <ittium@gmail.com>
Newsgroups comp.lang.c++
Subject Re: C++ standard library and exceptions
Date 2011-12-08 16:35 +0530
Organization A noiseless patient Spider
Message-ID <4EE09A0D.2020602@gmail.com> (permalink)
References <jbpml4$u85$1@dont-email.me> <5230ac9e-7a6e-41c4-ba3e-1a8f37e9c9c0@d10g2000vbk.googlegroups.com>

Show all headers | View raw


On 12/8/2011 2:32 PM, Goran wrote:
> On Dec 8, 7:47 am, ittium<itt...@gmail.com>  wrote:
>> Groups,
>> I have been using C++ for last couple of years, only exception from
>> standard library (+STL) that I ever worried was bad_alloc from new.
>> Lately I have been reading about exception and It appears large numbers
>> of routine can throw exception.
>
> Yes, however, AFAIK, all of them throws indicate a serious bug in your
> program. Do you want to continue running even though you stepped on a
> bug? I think not.
>
> The only potential exception I know of is vector resize, when you
> might get length_error because elem_size*elem_count if over address
> space size.
>
>> I was wondering what is the best way to
>> find out the list of exception a standard library routine can throw.
>
> I don't know, but I know this: that's the wrong way of working with
> exceptions. In a vast majority of cases you simply don't want to know
> what exception types are. What you do need, though, is whether some
> routine can throw or not (and even that, not that often, only when you
> have a piece of no-throw code and you do work with some STL element in
> it).
>
> Could you given an example of why you think it's important to know the
> type of the exception? I'll try to show you how to do it so that it
> isn't.
>
>> I
>> am actually looking for **some kind** of standard man pages, that talks
>> about exceptions apart from method signatures and return values.
>
> I know of none. But, due to what I think about that, see above, I
> didn't look very hard.
>
> Further, I believe that specifying such a list would hinder further
> development of the library, and would also hinder what's available to
> implementation to e.g. improve debugging facilities. If such list was
> prescribed, you might easily get have non-compliant error-checking
> facilities checks in a debug version (or even in release), or make
> creation/use of such facilities harder.
>
> Goran.

Thanks Goran, for a very detailed explanation. Please correct me if I am 
wrong. This is what you are saying

It is not a good idea to catch the exception thrown from standard 
library routine, such a exception is a condition that you can not 
recover except in following cases
1. bad_allocation (Although handling this may also be a very difficult, 
you have to employ things like reserving memory for such condition. May 
be in few cases you can recover.)
2. vector length error
We should not try to catch other exceptions (using catch). When such 
exception occur, default behavior (terminate) will take place and 
program will dump core.

Ittium


Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

C++ standard library and exceptions ittium <ittium@gmail.com> - 2011-12-08 12:17 +0530
  Re: C++ standard library and exceptions ittium <ittium@gmail.com> - 2011-12-08 12:22 +0530
  Re: C++ standard library and exceptions Goran <goran.pusic@gmail.com> - 2011-12-08 01:02 -0800
    Re: C++ standard library and exceptions ittium <ittium@gmail.com> - 2011-12-08 16:35 +0530
      Re: C++ standard library and exceptions Goran <goran.pusic@gmail.com> - 2011-12-08 05:08 -0800
        Re: C++ standard library and exceptions ittium <ittium@gmail.com> - 2011-12-10 13:46 +0530
          Re: C++ standard library and exceptions "io_x" <a@b.c.invalid> - 2011-12-11 05:43 +0100
            Re: C++ standard library and exceptions "io_x" <a@b.c.invalid> - 2011-12-12 03:21 +0100
            Re: C++ standard library and exceptions André Gillibert <MetaEntropy.removeThis@gmail.com> - 2011-12-12 11:15 +0100
              Re: C++ standard library and exceptions Nobody <nobody@nowhere.com> - 2011-12-12 12:59 +0000
              Re: C++ standard library and exceptions Kaz Kylheku <kaz@kylheku.com> - 2011-12-12 17:28 +0000
                Re: C++ standard library and exceptions Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-12 12:42 -0600
                Re: C++ standard library and exceptions Joshua Maurice <joshuamaurice@gmail.com> - 2011-12-12 14:18 -0800
                Re: C++ standard library and exceptions Sektor van Skijlen <ethouris@gmail.com> - 2011-12-19 02:38 -0800
                Re: C++ standard library and exceptions 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-19 03:52 -0800
              Re: C++ standard library and exceptions "io_x" <a@b.c.invalid> - 2011-12-13 09:16 +0100
              Re: C++ standard library and exceptions "io_x" <a@b.c.invalid> - 2011-12-13 09:17 +0100
                Re: C++ standard library and exceptions "Wolfgang.Draxinger" <Wolfgang.Draxinger@physik.uni-muenchen.de> - 2011-12-15 12:14 +0100
                Re: C++ standard library and exceptions Joshua Maurice <joshuamaurice@gmail.com> - 2011-12-15 15:50 -0800
                Re: C++ standard library and exceptions hanukas <jukka@liimatta.org> - 2011-12-17 21:57 -0800
                Re: C++ standard library and exceptions "io_x" <a@b.c.invalid> - 2011-12-19 04:02 +0100
                Re: C++ standard library and exceptions Joshua Maurice <joshuamaurice@gmail.com> - 2011-12-19 01:32 -0800
                Re: C++ standard library and exceptions Tobias Müller <troplin@bluewin.ch> - 2011-12-19 07:14 +0000
                Re: C++ standard library and exceptions Joshua Maurice <joshuamaurice@gmail.com> - 2011-12-19 01:29 -0800

csiph-web