Results 1 to 4 of 4

Thread: exceptions catching

  1. exceptions catching

    Друзья, похоже мы наткнулись на оччеень неприятный баг в 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
    Эксшепн не словился! Как так? И как это полечить?

  2. #2
    Join Date
    Mar 2007
    Location
    Moscow
    Posts
    40
    а если сделать так?

    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;
    }

  3. #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

  4. Похоже, известный баг в uclibc:
    http://uclibc.org/lists/uclibc/2006-July/015989.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •