C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] unreachable control flow

From: Jₑₙₛ Gustedt <jens.gustedt_at_[hidden]>
Date: Tue, 18 May 2021 17:59:56 +0200
Miguel,

on Tue, 18 May 2021 17:44:08 +0200 you (Miguel Ojeda via Liaison
<liaison_at_[hidden]>) wrote:

> On Tue, May 18, 2021 at 11:42 AM Andrew Banks via Liaison
> <liaison_at_[hidden]> wrote:
> >
> > Don't we already have perror() for that?
> >
> > If ( fatal condition )
> > {
> > perror( "Something informative" );
> > abort();
> > }
>
> That is about informing the user. I was referring to the reader of the
> code. Assuming this is the aborting one:
>
> if (c)
> unreachable();
>
> is at the same time more explicit and less verbose than:
>
> if (c) {
> // Unreachable
> abort();
> }

I think that the two are really not the same. Calling `abort()` has
defined behavior, it forces the implementation to branch conditionally
and to terminate the execution if the branch is taken. My idea of
`unreachable` would be that the implementation may produce code they
want, and in particular they may remove the test of the condintional
and unreachable branch completely. It is the user's responsibility to
make sure that this ok, it is the compiler's responsibility to make the
best from that assumption.

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-18 11:00:28