Is this a compilation error typedef int (* j) () throw (A)?

#include <iostream> class A {}; typedef int (*j)() throw(A); int f() { std::cout << "function f" << std::endl; return 0; } int main() { jy = f; y(); } 

On all sites, Stroustrup also says that it will compile the error, but it compiles. Are there any changes to the standard?

+6
source share
2 answers

I know this is not the answer to this question -

MSVC 2010 (I have) does not cause errors, compiles and works without hiccups

g ++ (GNU) says error: 'j' declared with an exception specification

Klang says error: exception specifications are not allowed in typedefs

Bottomline: Compiler Error in MSVC.

+2
source

Exception specifications are not part of the function type. For example, you cannot overload them; and a function pointer does not carry an exception specification. As @Aniket says, this is a Microsoft bug that the compiler accepts in this declaration.

0
source

All Articles