|Skip Navigation Links|
|Exit Print View|
|Oracle Solaris Studio 12.3: C++ User's Guide Oracle Solaris Studio 12.3 Information Library|
The C++ standard says that an overriding virtual function must not be less restrictive in the exceptions it allows than any function it overrides. It can have the same restrictions or be more restrictive. Note that the absence of an exception specification allows any exception.
Suppose, for example, that you call a function through a pointer to a base class. If the function has an exception specification, you can count on no other exceptions being thrown. If the overriding function has a less-restrictive specification, an unexpected exception could be thrown, which can result in unexpected program behavior followed by a program abort.
When you use -features=extensions, the compiler will allow overriding functions with less-restrictive exception specifications.