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


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

Re: like to know why it is segmentation fault on simple throw-exception program

From Victor Bazarov <v.bazarov@comcast.invalid>
Newsgroups comp.lang.c++
Subject Re: like to know why it is segmentation fault on simple throw-exception program
Date 2011-06-02 07:59 -0400
Organization A noiseless patient Spider
Message-ID <is7tvf$4ug$1@dont-email.me> (permalink)
References (2 earlier) <is6epo$kki$1@dont-email.me> <94ntlmF12lU14@mid.individual.net> <is6fgk$ntt$2@dont-email.me> <49d055a9-79d3-4e35-b8c8-7101bbc845d0@l2g2000prg.googlegroups.com> <Xns9EF8563A3F8B5myfirstnameosapriee@216.196.109.131>

Show all headers | View raw


On 6/2/2011 1:28 AM, Paavo Helde wrote:
> eric<cneric12lin0@gmail.com>  wrote in
> news:49d055a9-79d3-4e35-b8c8-7101bbc845d0@l2g2000prg.googlegroups.com:
>
>> Dear Victor or advanced c++ program(especially on g++ camp):
>>    I follow many of your suggestion, ie change&&  to || in push
>> then
>> after it run
>> -------------
>> terminate called after throwing an instance of 'char const*'
>> Aborted
>> ----------this is better than Segmentation fault, but still not
>> expected-------
>
> It looks like you still throw a char* pointer instead of bound_err, against
> Victor's suggestions. Calling terminate() is expected behavior to me in
> this case (and also demonstrates why (non-empty) exception specifications
> are bad).

IOW, try changing your

     throw ("blah");
to
     throw bound_err("blah");

or change your 'catch' code to catch a pointer to const char *and* drop 
the exception specification.  Your function does not throw what it is 
declared to throw.

V
-- 
I do not respond to top-posted replies, please don't ask

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


Thread

like to know why it is segmentation fault on simple throw-exception program eric <cneric12lin0@gmail.com> - 2011-06-01 15:01 -0700
  Re: like to know why it is segmentation fault on simple throw-exception program Ian Collins <ian-news@hotmail.com> - 2011-06-02 10:16 +1200
    Re: like to know why it is segmentation fault on simple throw-exception program Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-01 18:34 -0400
      Re: like to know why it is segmentation fault on simple throw-exception   program Ian Collins <ian-news@hotmail.com> - 2011-06-02 10:44 +1200
        Re: like to know why it is segmentation fault on simple throw-exception   program Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-01 18:46 -0400
          Re: like to know why it is segmentation fault on simple throw-exception program eric <cneric12lin0@gmail.com> - 2011-06-01 20:07 -0700
            Re: like to know why it is segmentation fault on simple throw-exception program Paavo Helde <myfirstname@osa.pri.ee> - 2011-06-02 00:28 -0500
              Re: like to know why it is segmentation fault on simple throw-exception program Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-02 07:59 -0400
        Re: like to know why it is segmentation fault on simple throw-exception program red floyd <redfloyd@gmail.com> - 2011-06-02 11:20 -0700
  Re: like to know why it is segmentation fault on simple throw-exception program Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-01 18:44 -0400

csiph-web