RAD Studio |  |

W8078: Throw expression violates exception specification (C++)

(Command-line option to suppress warning: -w-thr)

This warning happens when you add an exception specification to a function definition and you throw a type in your function body that is not mentioned in your exception specification.

The following program would generate this warning:

Copy Code

    int foo() throw(char*)  // I promise to only throw char*s

Copy Code

    {

Copy Code

        throw 5;  // Oops, I threw an integer

Copy Code

        return 0;

Copy Code

    }

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!