Re: unexpected exception handler



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
.



Relevant Pages

  • Re: performance
    ... efficient language and still have an inefficient system. ... > Even on these super performant silicons, some kernel code and device drivers ... > exceptions. ... > relates to the efficiency/performance of the libraries ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: performance
    ... ;-)) still use plain C code for some kernel stuff and some parts are still ... Even on these super performant silicons, some kernel code and device drivers ... exceptions. ... relates to the efficiency/performance of the libraries ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: When to introduce exception safety
    ... | context of exceptions because it lacks exception safety -- well it might ... I'm sure libraries like this exist, and we have to somehow work ... | If a dtor throws all bets are off. ... But how do you guarantee that a given destructor will not throw? ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Setting the FPU Control Word on application startup
    ... floating point exceptions be disabled at all times. ... libraries expect the FPU exceptions to be disabled because the Microsoft ...
    (borland.public.delphi.non-technical)
  • Re: Any non-GNU compilers? sick of GNU copylefts
    ... >> Compiling comercial products statically and selling them is prohibited ... >> with the libs source code and link everything dynamically. ... each of the libraries as well as ... typically use exceptions, so this is the right thing to do. ...
    (comp.unix.bsd.openbsd.misc)

Loading