C++ Logo

std-discussion

Advanced search

Re: Is forward progress guarantee still useful?

From: Yongwei Wu <wuyongwei_at_[hidden]>
Date: Fri, 19 Sep 2025 12:18:02 +0800
On Fri, 19 Sept 2025 at 04:59, Thiago Macieira via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> On Thursday, 18 September 2025 03:55:01 Pacific Daylight Time David Brown via
> Std-Discussion wrote:
> > A tight infinite loop (like gcc) would be reasonable,
> > as would an "UB" or trap instruction that guarantees a program halt on a
> > hosted OS like Linux is a better choice.
>
> One could reason the opposite. This is the case of the time-travelling UB: the
> compiler is allowed to reason UBs never happen, so it is allowed to eliminate
> all code paths that would have led there. That implies Clang implemented the
> infinite loop as obscure way to write:
> __builtin_unreachable();

This is exactly the reason I dislike UB. Getting rid of code that has
no side effects is one thing (David Brown kind of persuaded me),
having a licence to do crazy things is another.

It is better to have fews UBs. In my eyes, they have too much collateral damage.

-- 
Yongwei Wu
URL: http://wyw.dcweb.cn/

Received on 2025-09-19 04:18:16