C
Chris
Hello all...
I have a program with the following structure (all classes
mentioned are of my own creation, and none of the classes contain try
or catch blocks):
- main() consists of a large try block with several catch blocks I
will describe below. main(), within the try block, declares, and
implicitly default-constructs, a variable (object) of class AppDBConn.
- The default AppDBConn constructor uses initialization syntax to
invoke a one-argument (std::string) constructor of its base class
IniDBConn.
- The one-argument IniDBConn constructor uses 'new' to construct an
IniFile object, again passing one argument (std::string). (IniFile
derives separately from IniCheck.)
- There is a hierarchy of exception classes: IniError derives from
RunError, which derives from Error, which is a base class.
My problem is this: main() has catch blocks for IecIniError and
"..." (catch-all). The IniFile constructor encounters an error and
invokes a base-class (IniCheck) method to process it, which culminates
with the throwing of an IniError. None of main()'s catch blocks --
including the catch-all block -- catch this, and the program SEGVs
instead of terminating gracefully.
By way of troubleshooting, If I eliminate main()'s use of
AppDBConn, and instead construct an IniDBConn object directly, the
problem remains; the thrown exception is not caught.
If I eliminate main()'s use of AppDBConn -and- IniDBConn, and
construct an IniFile object directly, the problem disappears; the
thrown exception IS caught, in main()'s catch block for IniError.
I need to fix this misbehavior, but am at a loss to do so. My
questions are:
1) Are there any coding (mis)constructs that cause this?
2) Could it be a problem with the OS (SuSE Linux 9) and/or compiler
(g++ 3.3.3)?
3) What else might I be overlooking?
I would be grateful for any light anyone could shed.
Thanks in advance,
Chris
I have a program with the following structure (all classes
mentioned are of my own creation, and none of the classes contain try
or catch blocks):
- main() consists of a large try block with several catch blocks I
will describe below. main(), within the try block, declares, and
implicitly default-constructs, a variable (object) of class AppDBConn.
- The default AppDBConn constructor uses initialization syntax to
invoke a one-argument (std::string) constructor of its base class
IniDBConn.
- The one-argument IniDBConn constructor uses 'new' to construct an
IniFile object, again passing one argument (std::string). (IniFile
derives separately from IniCheck.)
- There is a hierarchy of exception classes: IniError derives from
RunError, which derives from Error, which is a base class.
My problem is this: main() has catch blocks for IecIniError and
"..." (catch-all). The IniFile constructor encounters an error and
invokes a base-class (IniCheck) method to process it, which culminates
with the throwing of an IniError. None of main()'s catch blocks --
including the catch-all block -- catch this, and the program SEGVs
instead of terminating gracefully.
By way of troubleshooting, If I eliminate main()'s use of
AppDBConn, and instead construct an IniDBConn object directly, the
problem remains; the thrown exception is not caught.
If I eliminate main()'s use of AppDBConn -and- IniDBConn, and
construct an IniFile object directly, the problem disappears; the
thrown exception IS caught, in main()'s catch block for IniError.
I need to fix this misbehavior, but am at a loss to do so. My
questions are:
1) Are there any coding (mis)constructs that cause this?
2) Could it be a problem with the OS (SuSE Linux 9) and/or compiler
(g++ 3.3.3)?
3) What else might I be overlooking?
I would be grateful for any light anyone could shed.
Thanks in advance,
Chris