c++ - 在一个函数前面加[[noreturn]]是什么意思?
怪我咯
怪我咯 2017-04-17 15:36:26
0
1
992
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
阿神

This is C++11'sattribute specifier sequence( http://en.cppreference.com/w/... )

About [[noreturn]], the official explanation is

Indicates that the function does not return.
This attribute applies to function declarations only. The behavior is undefined if the function with this attribute actually returns.

The specifier is used for 指示函数永不返回.
helps the compiler to perform 编译优化 (such as tail recursion, etc.).
can also be used for 抑制编译器给出不必要的警告 (such as int f(); f();, without adding [[noreturn]], the compiler will warn that the return value of f() is ignored)

However, if the function does have a return value and you specify [[noreturn]], this is undefined behavior

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template