а если сделать так?
int main () {
cout << "Exception test" << endl;
try
{
throw 20;
}
catch (int e)
{
cout << "An exception occurred. Exception Nr. " << e << endl;
}
catch (...)
{
cout << "An unknown exception occurred" << endl;
}
Друзья, похоже мы наткнулись на оччеень неприятный баг в uclibc, для иллюстрации покажу небольшу программу:
Компилирую ее с помощью:Code:[dfayruzov@wl500g dfayruzov]$ cat extest.cc #include <iostream> using namespace std; int main () { cout << "Exception test" << endl; try { throw 20; } catch (int e) { cout << "An exception occurred. Exception Nr. " << e << endl; } cout << "End." << endl; return 0; }
Запускаю, и:Code:g++ -o extest extest.cc
Эксшепн не словился! Как так? И как это полечить?Code:[dfayruzov@wl500g dfayruzov]$ ./extest Exception test terminate called after throwing an instance of 'int' Aborted
а если сделать так?
int main () {
cout << "Exception test" << endl;
try
{
throw 20;
}
catch (int e)
{
cout << "An exception occurred. Exception Nr. " << e << endl;
}
catch (...)
{
cout << "An unknown exception occurred" << endl;
}
#include <iostream>
#include <iostream>
using namespace std;
int main () {
cout << "Exception test" << endl;
try
{
throw 20;
}
catch (int e)
{
cout << "An exception occurred. Exception Nr. " << e << endl;
}
catch (...)
{
cout << "An unknown exception occurred" << endl;
}
cout << "End." << endl;
return 0;
}
~
[dfayruzov@wl500g dfayruzov]$ g++ -o extest2 extest2.cc
[dfayruzov@wl500g dfayruzov]$ ./extest2
Exception test
terminate called after throwing an instance of 'int'
Aborted
Похоже, известный баг в uclibc:
http://uclibc.org/lists/uclibc/2006-July/015989.html