C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] unreachable control flow

From: Jₑₙₛ Gustedt <jens.gustedt_at_[hidden]>
Date: Sun, 16 May 2021 16:26:00 +0200
Miguel,

on Sun, 16 May 2021 16:03:05 +0200 you (Miguel Ojeda
<miguel.ojeda.sandonis_at_[hidden]>) wrote:

> On Sun, May 16, 2021 at 12:13 PM Jₑₙₛ Gustedt via Liaison
> <liaison_at_[hidden]> wrote:
> >
> > Is there interest / attempt / opposition of porting this feature to
> > C?
>
> Sounds good to me.
>
> Rust and Zig also provide it equivalent facilities, although Rust
> provides both a safe version (panic) and an unsafe one (UB), which
> could be worth having; and Zig provides a single one that is a panic
> or UB depending on compilation mode.
>
> So a couple questions for (both) papers would be:
>
> - Should we have a non-UB variant that e.g. `abort()`s, like Rust?

we have that already, it is called `abort`, and if we also get `defer`
in C23 we will have `panic` ;-)

More seriously, I don't think we should provide more than that,
because if we want as specific behavior in case of violation of the
constraint, the compiler would always do the test. But one goal of
such a thing would be to make agressive optimizations possible.

> - Should behavior depend on `NDEBUG`/`_DEBUG`/build "mode" or
> similar, like Zig?

Would the behavior then be different from `assert(false)` ?

I think the paper talks of something very similar that could be called
`assume(false)` and argues against it.

Thanks
Jₑₙₛ

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2021-05-16 09:26:08