Re: unexpected exception handler
- From: Tamas Demjen <tdemjen@xxxxxxxxx>
- Date: Wed, 09 Jan 2008 10:37:36 -0800
George wrote:
Do you think from technical point of view, it is possible to list all the exceptions? I am not sure whether there are any potential exceptions at runtime which we do not know at development time.
It is very unlikely. The operating system itself can't throw C++ exceptions. 3rd party libraries without source code don't throw either, because in C++ you can't throw an exception in a binary portable way. You can't throw an exception from a DLL, and if it's a LIB, it's almost always written in native C. In order to link a static C++ LIB to your project, it has to use the same compiler, the same STL version, and the same compiler settings that your main project. For this reason 3rd party vendors almost never distribute C++ libraries in LIB format.
In other languages, such as Delphi, Java, C#, it is fairly common that a 3rd party library without source code throws. Not in C++.
A COM library may throw, but COM exceptions are marshaled. A COM exception is not a C++ exception, only ATL turns them into C++ exceptions. This is something developers know about, though. Similarly, a Web service can throw too, but a Web service exception is nothing more than an XML tag, and only the XML parser turns it into a C++ exception. Again, it's documented in the library.
STL and boost both can throw, but they come with full source code and documentation. There should be no surprise there.
There are unexpected situations, such as access violations and division by 0, but they're not C++ exceptions:
try
{
void* p = 0;
*p = 0;
}
catch(...)
{
// you normally can't catch this in VC++ 2005, 2008
}
So what remains is a mystery C++ LIB file from an unreliable source that you have absolutely no knowledge of. That may throw without your knowledge. But if you link that to your project, you are asking for *major* trouble anyway. I would avoid doing that at all cost.
Tom
.
- Follow-Ups:
- Re: unexpected exception handler
- From: George
- Re: unexpected exception handler
- References:
- Re: unexpected exception handler
- From: Igor Tandetnik
- Re: unexpected exception handler
- From: George
- Re: unexpected exception handler
- From: Igor Tandetnik
- Re: unexpected exception handler
- From: Igor Tandetnik
- Re: unexpected exception handler
- From: George
- Re: unexpected exception handler
- Prev by Date: Re: How to control cpu usage
- Next by Date: Re: issues with cliext::map and cliext::hash_map
- Previous by thread: Re: unexpected exception handler
- Next by thread: Re: unexpected exception handler
- Index(es):
Relevant Pages
|
Loading