Subject: Re: [std-proposals] proposal: [[noexcept]] attribute
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-10-23 08:47:34
On 2019-10-23 15:53, Walt Karas via Std-Proposals wrote:
> I propose adding noexcept as an attribute.Â It would be used after a
> function call to a noexcept(false) function.Â It asserts that, in that
> context, the function will not throw any exceptions.
noexcept specifier not only documents the function as non-throwing. It
also guarantees that the function won't throw (the program will
terminate if it does). This kind of guarantee cannot be implemented with
an attribute because it is not allowed to have a mandatory behavior.
You could implement what you propose as a library extension:
template< typename F >
auto invoke_noexcept(F f) noexcept
> I also propose
> that, if a function that only has calls to noexcept functions, or calls
> with the [[noexcept]] attribute, the compiler must emit a diagnostic
> (presumably a warning) if the function is noexcept(false).
That means all current code will suddenly emit tons of warnings. Thanks,
STD-PROPOSALS list run by email@example.com
Standard Proposals Archives on Google Groups