Exception Specifications are Checked at Run Time

Exception Specifications are Checked at Run Time

A function can specify explicitly what type of exception it may throw. An exception specification, however, is not checked at compile time, but rather at run time:

 class X {};int f();        // no exception specification, can throw any type of exceptionvoid g(int j) throw(); // promises not to throw any exception at all{	  int result = f(); // if f throws an exception, g will violate its  guarantee not to throw an exception                               //still, this is a perfectly legal code}

There are several reasons for this runtime checking policy. In the example, f could be a legacy C function. It is impossible to force a C function to have an exception specification. Also, forcing the programmer to write unnecessary try/catch blocks in g (although f doesn’t throw any exception at all) is an unacceptable burden. For these reasons, an exception specification is checked at run time.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved