Subroutine could benefit from empty exception specification

Subroutines that do not throw any exceptions can benefit from an empty exception specification.

An exception specification enumerates the exceptions that could be thrown by a subroutine. This diagnostic indicates that the indicated subroutine only throws no exceptions. Therefore it is legal to add an empty exception specification, "throw()".

Even if exception specifications are not enforced (they are not enforced on Windows* OS), they still provide a useful documentation function. Users reading about the subroutine might be interested to know that it cannot throw any kind of exception and therefore it can be safely called without providing a catch block.

ID

Observation

Description

1

Definition

This shows where the subroutine was defined

Example

          
// exception specification indicates no exceptions can be thrown
int f(int x) throw()
{
    return 1;
}
        

Copyright © 2010, Intel Corporation. All rights reserved.