W8078 Throw expression violates exception specification (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

(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:

int foo() throw(char*)  // I promise to only throw char*s
{
    throw 5;  // Oops, I threw an integer
    return 0;
}