[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

exceptions in gnu c++



I've written a simulation program in c++. It works for
small problems of its class, but fails during initialization
on large problems. I suspect I need more RAM, but would
like confirmation, so ...

I changed the main program to include a everything in a
try block with a catch block, etc. But it still dies in
the same way. Where can I find an example of exception
handling code that works with gcc 3.3? 

My code is:
using namespace std;

#include "Sys.hh"
#include "nmlib.hh"
#include "rgen2.hh"
#include "nmsim.hh"

int main( int argc, char* argv[] ){
  cout<<"Starting nmmain..."<<endl;
  try {
    NMsim X;                 // instantiate the simulation object
    X.nminit( argc, argv ); // read in parameters and generate starting conditions
    X.nmcore( );         // do a simulation run
  } catch (const exception caught) {
    cout << "caught exception: "<<caught.what() <<"!!!"<< endl;
  }
  cout<<" After catch."<<endl;
  return 0;
};

NMsim::NMsim(){};

</end>

The output is:
gq:/da4/wdl/H$ nmmain --steps 200 --stpsiz 200 --kernparm 1024. vaa.a
Starting nmmain...
init set to 255
 done with tbl/abn/sid preparation
 start dispersal calc with rx=5418
 row: 21100     128    Killed
gq:/da4/wdl/H$
</end>

Notice the 'debug' statements being sent to cout.
'Killed' comes from some gcc library, not from my code, 
especially not from my catch block. The detailed
syntax that I'm attempting to use is taken from
Josuttis, p. 15. He footnotes it with a caveat that
it is not in the Standard, only proposed. Looks like
something in the c++ library is catching whatever
is being thrown (if anything) and killing nmmain
before control gets to my catch and/or return stmnts.

suggestions? (like maybe a more appropriate list to ask?)

-- 
Paul E Condon           
pecondon@mesanetworks.net



Reply to: