Search code examples
c++c++11clangfunction-pointersnoreturn

[[noreturn]] function pointer


When I use clang (version 3.4 (trunk 194574)) to compile this:

typedef void (* FunctionThatNeverReturns [[ noreturn ]])();

I get this:

error: 'noreturn' attribute only applies to functions and methods

That surprises me because it worked perfectly fine with an older version of clang.

So how can I define a pointer to a [[ noreturn ]] function?

I need this because I'm calling the function pointer inside a [[ noreturn ]] function which obviously produces a warning if the function pointer is not marked as noreturn.

Oh, and this works:

typedef void (* FunctionThatNeverReturns [[ gnu::noreturn ]])();

But is there no compiler-independent solution?


Solution

  • As indicated in the comments, this is apparently prohibited by the standard.