Catching standard exceptions

A

Alex Vinokur

------------------------
Visual C++ 6.0
Debug Mode
-----------------------

I have the following piece of code:

================
int* p;

try
{
p = new int [0x7FFFFFFF];
}
catch (exception& e)
{
cout << "Standard exception: " << e.what() << endl;
}
================

'new' failed, but system has catched the exception, not my catch.
The message "Standard exception: <text from e.what>" hasn't been shown.
System error message box (with relevant text) has been shown.

Why doesn't work catch in code below?

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
 
J

John Carson

Alex Vinokur said:
------------------------
Visual C++ 6.0
Debug Mode
-----------------------

I have the following piece of code:

================
int* p;

try
{
p = new int [0x7FFFFFFF];
}
catch (exception& e)
{
cout << "Standard exception: " << e.what() << endl;
}
================

'new' failed, but system has catched the exception, not my catch.
The message "Standard exception: <text from e.what>" hasn't been
shown. System error message box (with relevant text) has been shown.

Why doesn't work catch in code below?

Because VC++ is a pre-standard compiler. There is a workaround in this case.

http://support.microsoft.com/?kbid=167733
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top