Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this compile 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()
{ 
    j y = f;
    y();
}

In all sites and Stroustrup too says that there will be compile error, but it compiles. Are there any changes in standard?

like image 745
STL programmer Avatar asked Mar 17 '13 07:03

STL programmer


1 Answers

I know this is not an answer to this question -

MSVC 2010(that I have) throws no error, compiles fine and works without a hiccup

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

Clang says error: exception specifications are not allowed in typedefs

Bottomline: Compiler bug in MSVC.

like image 91
Aniket Inge Avatar answered Oct 07 '22 15:10

Aniket Inge