C++ Logo


Advanced search

Re: Remove infinite loop UB

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 11 May 2020 10:59:22 -0700
On Sunday, 10 May 2020 18:02:15 PDT connor horman via Std-Proposals wrote:
> Though that leaves room for a lower level language, C or even Rust (which
> also has a valid infinite looping construct loop{}, which the fact it is
> infinite is relied upon for soundness).
> I would argue that where a user intends to invoke an infinite loop, and
> that intention is clearly communicated (condition of for/while/do-while is
> either a contextually converted constant expression of type bool, which
> after conversions evaluates to true, or the condition of for is omitted),
> the construct should be permitted. It harms embedded use cases (what about
> processors that don't have a STP instruction); can be surprising for people
> coming into C++ from other languages that do have endless looping
> constructs, including C; and even serves to limit the common subset between
> languages further.

The problem is that we've so found far exactly one valid use-case for an
infinite loop without any visible progress and it's really, really rare. I
don't think the language needs to change to accommodate it, if there are other
solutions and if even C++ can do that by having a library function do it.

This function could be called "exit".
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2020-05-11 13:02:40