[PATCH] D21232: Add attribute noreturn to functions that throw

Aditya Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 14:11:18 PDT 2016


hiraditya added a comment.

In https://reviews.llvm.org/D21232#524419, @mclow.lists wrote:

> > The noreturn keyword does not affect the exceptional path when that applies: a noreturn-marked function may still return to the caller by throwing an exception or calling longjmp.
>
>
> I learn something new every day :-)
>  In that case, we can lose the `_LIBCPP_NORETURN_ON_EXCEPTIONS` macro altogether, and just mark those functions with `_LIBCPP_NORETURN` - which I think was the original proposal.
>
> Sorry for the confusion.




In https://reviews.llvm.org/D21232#524625, @kparzysz wrote:

> http://en.cppreference.com/w/cpp/language/attributes
>
> > [[noreturn]]	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 following standard functions have this attribute: std::_Exit, std::abort, std::exit, std::quick_exit, std::unexpected, std::terminate, std::rethrow_exception, std::throw_with_nested, std::nested_exception::rethrow_nested
>


From: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf
7.6.3 Noreturn attribute [dcl.attr.noreturn]

#2 If a function f is called where f was previously declared with the noreturn attribute and f eventually
returns, the behavior is undefined. [ Note: The function may terminate by throwing an exception. —end
note ] [ Note: Implementations are encouraged to issue a warning if a function marked [[noreturn]] might
return. —end note ]


https://reviews.llvm.org/D21232





More information about the llvm-commits mailing list