Posted by
Xavier.Abulker on
URL: http://quantlib.414.s1.nabble.com/Re-exception-handling-on-Unix-tp2571p2575.html
Hi James,
thanks very much for this answer it sounds like a very good idea.
Excuse me if the email was not very clear.
My main problem is that I can't catch any quantlib exception, I always
receive a core dump.
For example this command:
EuropeanOption opt(Option::Put,147.5,-1.0,0.0,0.03,0.0986,0.2);
doesn't give me the expected quantlib error "Strike must be positive" but
a core dump.
Could you give me more clue, should I remove the ~Error() throw() {}?
Thanks again
Xavier
"James Dalby"
<
[hidden email] To: <
[hidden email]>
om> cc:
Subject: RE: [Quantlib-users] exception handling on Unix
20/06/2003
15:04
Xavier,
I'm deeply suspicious of the 'throw()' in the destructor ~Error()
This will be invoked at the end of the 'catch' block as the (copy
contructed) exception 'e' is deleted. There is nothing to catch the
'throw()' and so the program will crash.
I hope this is some use to you. I apologise if I've misunderstood your
problem.
Kind regards,
James
-----Original Message-----
From:
[hidden email]
[mailto:
[hidden email]]On Behalf Of
[hidden email]
Sent: Friday, June 20, 2003 1:41 PM
To:
[hidden email]
Cc:
[hidden email];
[hidden email]
Subject: Re: [Quantlib-users] exception handling on Unix
Hi Luigi,
I'm still facing the same issue to handle QL exceptions on Unix, I tried to
debug the program but I'd like to ask you some help.
I tried to compile with the last version of GCC and last version of
Quantlib and nothing works; still the same core dump.
I tried to compile with other options like -lstdc++ or shared-libgcc but
still the same core dump.
I tried a main source code like:
int main() {
try {
QL_REQUIRE(1 < 0.0,"exception");
} catch (std::exception& e) {
std::cout<<"in exception"<<std::endl;
std::cerr << e.what() << std::endl;
return 1;
}
}
and here it works, it gives me the "in exception exception".
Now in debug mode I see that the program goes until \ql\errors.hpp at this
level:
class Error : public std::exception {
public:
explicit Error(const std::string& what = "") : message(what) {}
~Error() throw() {}
and here it crashes (certainly outside of errors.hpp)
It's now getting hard to debug and I 'd like to know if you have an idea on
what I could do to follow in analysing the problem and solve it.
Thanks for your help
Xavier
Xavier ABULKER
To: Luigi Ballabio
<
[hidden email]>
21/05/2003 cc:
[hidden email],
15:27
[hidden email]
Subject: Re: [Quantlib-users]
exception handling on Unix
(Document link: Xavier ABULKER)
Hi Luigi,
this second example gives me the error:
"
~/QuantLib-0.3.1/Examples/EuropeanOption> make
source='EuropeanOption.cpp' object='EuropeanOption.o' libtool=no \
depfile='.deps/EuropeanOption.Po' tmpdepfile='.deps/EuropeanOption.TPo' \
depmode=gcc /bin/bash ../../config/depcomp \
g++ -DHAVE_CONFIG_H -I. -I. -I../../ql -I../.. -I../.. -c -o
EuropeanOption.o `test -f 'EuropeanOption.cpp' || echo './'
`EuropeanOption.cpp
EuropeanOption.cpp: In function `int main()':
EuropeanOption.cpp:29: parse error before `)'
EuropeanOption.cpp:32: no matching function for call to
`QuantLib::Instruments::VanillaOption::VanillaOption
(QuantLib::Option::Type,
QuantLib::RelinkableHandle<QuantLib::MarketElement> &, double,
QuantLib::RelinkableHandle<QuantLib::TermStructure> &,
QuantLib::RelinkableHandle<QuantLib::TermStructure> &,
QuantLib::EuropeanExercise,
QuantLib::RelinkableHandle<QuantLib::BlackVolTermStructure> &,
QuantLib::Handle<QuantLib::PricingEngine> (&)(...))'
../../ql/Instruments/vanillaoption.hpp:51: candidates are:
QuantLib::Instruments::VanillaOption::VanillaOption(QuantLib::Option::Type,
const QuantLib::RelinkableHandle<QuantLib::MarketElement> &, double, const
QuantLib::RelinkableHandle<QuantLib::TermStructure> &, const
QuantLib::RelinkableHandle<QuantLib::TermStructure> &, const QuantLib::Date
&, const QuantLib::RelinkableHandle<QuantLib::MarketElement> &, const
QuantLib::Handle<QuantLib::PricingEngine> &, const string & = "", const
string & = "")
../../ql/Instruments/vanillaoption.hpp:100:
QuantLib::Instruments::VanillaOption::VanillaOption(const
QuantLib::Instruments::VanillaOption &)
*** Error code 1
make: Fatal error: Command failed for target `EuropeanOption.o'
"
I'm currenlty Sad advice: use gcc -lstdc++ instead of g++
Thank you for your help
Xavier
Luigi Ballabio
<
[hidden email]> To:
[hidden email]
Sent by: cc:
[hidden email]
[hidden email] Subject: Re:
[Quantlib-users] exception handling on Unix
eforge.net
21/05/2003 13:18
Xavier,
would you mind trying this file?
(See attached file: foo.cpp)
*************************************************************************
Ce message et toutes les pieces jointes (ci-apres le "message") sont
confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration.
La Fimat et ses filiales declinent toute responsabilite au
titre de ce message s'il a ete altere, deforme ou falsifie.
********
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration.
Neither Fimat nor any of its subsidiaries or affiliates shall
be liable for the message if altered, changed or falsified.
*************************************************************************
*************************************************************************
Ce message et toutes les pieces jointes (ci-apres le "message") sont
confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration.
La Fimat et ses filiales declinent toute responsabilite au
titre de ce message s'il a ete altere, deforme ou falsifie.
********
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration.
Neither Fimat nor any of its subsidiaries or affiliates shall
be liable for the message if altered, changed or falsified.
*************************************************************************