Date: Fri, 4 Sep 2026 16:55:00 +0200
On 9/4/26 12:51, Frederick Virchanza Gotham via Std-Proposals wrote:
> If you mark a function as 'noexcept(false)', it is free to throw an
> exception up to its caller.
>
> If you mark a function as 'noexcept' or 'noexcept(true)', it will
> never throw an exception up to its caller -- but only because
> 'std::terminate' gets called instead.
>
> If you mark a function as 'noexcept(static)', it will never throw an
> exception up to its caller -- because you'll get a compile-time error
> if any statement inside the function body might throw.
This is a step backwards from noexcept(expression), because it removes
the expression. An expression cannot return `static`. If a statically
checked noexcept is a thing, then there should be a way to optionally
enable it for template functions.
> extern "C" noexcept(static) {
> #include "someClibrary.h"
> }
If it's an external library, then there's no way to statically check if
it throws, even if the library is exposed through a C interface. So
there are two possibilities:
* The compiler performs no checking in this case, which turns
noexcept(static) into a lie.
* The compiler's check fails, and the program fails to compile.
Which one should it be?
> If you mark a function as 'noexcept(false)', it is free to throw an
> exception up to its caller.
>
> If you mark a function as 'noexcept' or 'noexcept(true)', it will
> never throw an exception up to its caller -- but only because
> 'std::terminate' gets called instead.
>
> If you mark a function as 'noexcept(static)', it will never throw an
> exception up to its caller -- because you'll get a compile-time error
> if any statement inside the function body might throw.
This is a step backwards from noexcept(expression), because it removes
the expression. An expression cannot return `static`. If a statically
checked noexcept is a thing, then there should be a way to optionally
enable it for template functions.
> extern "C" noexcept(static) {
> #include "someClibrary.h"
> }
If it's an external library, then there's no way to statically check if
it throws, even if the library is exposed through a C interface. So
there are two possibilities:
* The compiler performs no checking in this case, which turns
noexcept(static) into a lie.
* The compiler's check fails, and the program fails to compile.
Which one should it be?
-- Rainer Deyke - rainerd_at_[hidden]
Received on 2026-09-04 14:55:12
