C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] unreachable control flow

From: Miguel Ojeda <miguel.ojeda.sandonis_at_[hidden]>
Date: Tue, 18 May 2021 17:44:08 +0200
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();
   }

Plus tooling around that is easier to write vs. information in comments.

Cheers,
Miguel

Received on 2021-05-18 10:44:22