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


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

Re: C++ standard library and exceptions

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.c++
Subject Re: C++ standard library and exceptions
Date 2011-12-12 17:28 +0000
Organization A noiseless patient Spider
Message-ID <20111212092105.701@kylheku.com> (permalink)
References (2 earlier) <4EE09A0D.2020602@gmail.com> <7532cea1-40db-406c-b396-fc3a63e5df0b@m10g2000vbc.googlegroups.com> <4EE31545.3060802@gmail.com> <4ee43401$0$1389$4fafbaef@reader2.news.tin.it> <20111212111524.16a909e9@corefixtop.gillibert.homelinux.net>

Show all headers | View raw


On 2011-12-12, André Gillibert <MetaEntropy.removeThis@gmail.com> wrote:
> "io_x" <a@b.c.invalid> wrote:
>> +comp.lang.c
>> "ittium" <ittium@gmail.com> ha scritto nel messaggio
>> news:4EE31545.3060802@gmail.com...
>> > On 08-12-2011 PM 06:38, Goran wrote:
>> >> On Dec 8, 12:05 pm, ittium<itt...@gmail.com>  wrote:
>> >>> On 12/8/2011 2:32 PM, Goran wrote:
>> >>>
>> 
>> i actualy think:
>> all exceptions in C or C++ library, or whatsover library,
>> but division by 0, has to be turned off
>> 
>> all beahavour of seg fault or "abort()" in C or C++ library
>> or in each library, has to be minimized to 0
>> 
>> for this i say all function has to return a possible
>> error code
>> all function in C has no error code are badly thinked
>> 
>> this is valid too for API library OS too
>> 
>> 
>> 
>
> Followup-To: comp.lang.c++
>
> Do you mean that the behavior of segfault should be defined as throwing
> a standard C++ exception?
>
> Well-defined programs cannot have any segfault... Any program having a
> segfault is in inconsistent state. Important data may have been
> damaged, and there is no guarantee of any sort of recovery.

Sorry, that's a ridiculous assertion. Catching segfaults is a useful
software technique that can be used to do cool things.  A software emulator for
a CPU can catch a segfault to detect that writes are taking place to simulated
I/O space.  Garbage collectors can use segfaults. Some Lisp implementations
catch SIGSEGV as part of their garbage collector implementation. For instance
CLISP has a "libsigsegv" library for handling access violations and fixing them
up: 

http://libsigsegv.sourceforge.net/

> For the sake of security and data integrity, a good system detecting
> such an error, should kill/abort/terminate the program immediately.

That is a silly view. Detecting the error already provides security and
integrity.

In all advanced CPU architectures, exceptions store enough information so that
the handler can recover by fixing the situation and resuming the program (if
that makes sense).

Terminating the program isn't the only possibility.

Since architectures provide the capability, it means that higher level
languages which do not map the capability are crippled with respect to machine
language.

I.e. you have some better exception handling features at the instruction set
level than you do in C++.

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