Hi,
Here is a simple peace of code that came from an exercise book about C++.
I am at the exception chapter of my C++ book.
=======================================
#include <iostream>
using namespace std;
const int DefaultSize = 10;
int main ()
{
int top = 90;
int bottom = 0;
try
{
cout << "top / 2 = " << (top / 2) << endl;
cout << "top divided by bottom = ";
cout << (top / bottom) << endl;
cout << "top / 3 = " << (top / 3) << endl;
}
catch (...)
{
cout << "something has gone wrong!" << endl << flush;
}
cout << "Done." << endl;
return 0;
}
=======================================
Here is my g++ setup has installed on my system.
[RLe@LinuxFed11 ~]$ g++ -v
Utilisation des specs internes.
Target: x86_64-redhat-linux
Configuré avec: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux
Modèle de thread: posix
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC)
=======================================
Using a plain empty exception class and manual making a throw, works!
It might be possible that the (top / bottom) operation is using deep library like calls that aren't unwinding the exceptions.
Which bring me to think about the "--disable-libunwind-exceptions" parameter about.
Am I on the right track?
I finaly got gdb to work under Eclipse. One of my sub directory in the working path was named: "Listing and Exercises", look like that Eclipse wasn't providing a proper working directory to gdb.
I wasn't able to debug until renaming it to "ListExerPjt".
The debug session is showing an exception : "signal SIGFPE".
The question is why the exception isn't caught by the try-catch C++ mechanism in that context?
Regards,
RL