Welcome to MSDN Blogs Sign in | Join | Help

Channel 9: Ale Contenti and Louis Lafreniere - Understanding Exceptions and When/How to Handle Them

During Ale Contenti's first Channel 9 video (VC++ Safe Libraries and More) he was asked how the Safe CRT worked with exceptions.  This was a great question, but too much to handle at the time.  Ale suggested the topic was worth a whole other video...and so here it is!  Ale is joined in this video by Louis Lafreniere (developer on the backend) to give you the whole picture - including how exception handling is implemented (even describing the variations caused by different hardware) and optimized. You can find the new video here.

This video is deep, and at 55 minutes fairly long, so get a fresh coffee, allocate some time and sit down to enjoy this one.

Thanks Damien

Published Friday, September 21, 2007 1:32 PM by vcblog
Filed under: ,

Comments

# MSDN Blog Postings » Channel 9: Ale Contenti and Louis Lafreniere - Understanding Exceptions and When/How to Handle Them

Friday, September 28, 2007 5:55 PM by junlin

# re: Channel 9: Ale Contenti and Louis Lafreniere - Understanding Exceptions and When/How to Handle Them

Is there any way to catch the win32 exception generated when accessing an out-of-bound element in a std::vector using operator[]?  If there is, how?

Friday, September 28, 2007 10:56 PM by Stephan T. Lavavej [MSFT]

# re: Channel 9: Ale Contenti and Louis Lafreniere - Understanding Exceptions and When/How to Handle Them

That is called Structured Exception Handling (SEH), which is completely different from C++ exception handling.

Most applications should never attempt to intercept SEH.

What are you really trying to do?  You shouldn't be generating out-of-bounds accesses with op[] in the first place.

Thanks,

Stephan T. Lavavej, Visual C++ Libraries Developer

Saturday, September 29, 2007 4:04 PM by junlin

# re: Channel 9: Ale Contenti and Louis Lafreniere - Understanding Exceptions and When/How to Handle Them

Thanks for your reply, Stephan.  I understand we should check bounds with op[] in the first place.  But in reality, things like this do happen.  What I am trying to do is to catch SEH exceptions like this (or division by zero etc.), save the critical data and exit the application.

The trouble I have is the /EHa compiler option would not work for me.  I can catch division by zero SEH exception only with optimization turned off. I can not catch out-of-bound SEH exception in std::vector op[] at all.  Any suggestions?  

I am using Visual C++ 2005.

Thanks,

Junlin

Monday, October 01, 2007 6:33 PM by Sys64738

# re: Channel 9: Ale Contenti and Louis Lafreniere - Understanding Exceptions and When/How to Handle Them

My doubt for exceptions is the following.

Suppose that I want to use STL inside a COM server that I develop using ATL.

While it is possible to use C++ exceptions (e.g. the std::exception and derived classes) *inside* the COM server, my understanding is that it is not allowed to throw exceptions out of COM method boundaries. In fact, the HRESULTs should be the only option to signal errors outside COM methods boundaries.

So, to build quality code, do you suggest us to put try/catch( std::exception & ) blocks inside each COM object method implementation, to prevent C++ exceptions to escape COM object methods boundaries?

Thanks in advance, and congrats for the Channel 9 video.

Gio

Wednesday, October 03, 2007 5:04 PM by alecont

# re: Channel 9: Ale Contenti and Louis Lafreniere - Understanding Exceptions and When/How to Handle Them

Hi Gio,

Yes, that could be a viable solution.

New Comments to this post are disabled
 
Page view tracker