-Winvalid-noreturn warning

Hi,

We have the below code where this warning gets generated.

#include

[[noreturn]] inline void

abc () noexcept

{

std::terminate ();

}

using MyNoReturn = void (*) () noexcept;

//using MyNoReturn = std::add_pointer_t<decltype(abc)>;

[[noreturn]]

inline void IDontReturn () noexcept

{

std::terminate ();

}

[[noreturn]]

inline void

CallIDontReturn () noexcept

{

gvar ();

}

We have the used the below command to compile:
clang++ -std=c++17 -Wall -o runusing usingst.cpp

gcc does not show this warning.

Please let us know how we can use ‘using’ clause to declare function pointer to a function that does not return, so that this warning does not show up.

Regards,
Manu

FWIW, GCC does warn on similar code - the reason it doesn’t warn here is that the function is inline and never called, so GCC probably never analyses it (I pasted your code here and added a few cases to demonstrate GCC’s quirks compared to Clang’s here: https://godbolt.org/z/YM9q91bx1 )

So far as I can tell, noreturn isn’t carried on function types, so it isn’t possible to do what you want at the moment. That’s my rough understanding, at least.