C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Remove infinite loop UB
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-05-11 13:21:34


On Mon, 11 May 2020 at 21:00, Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> 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".

P1494 covers this problem in addition to others. We don't need to
invent anything that hasn't already
been invented, and proposed, too.


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups