C++ Logo

std-discussion

Advanced search

Re: Is forward progress guarantee still useful?

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Wed, 17 Sep 2025 09:38:59 +0100
Hi,

Note that P2809 is heading into C++26.

https://wg21.link/P2809

This makes the example program here defined.

It does not make every infinite loop defined.



On 17 September 2025 03:11:35 BST, Yongwei Wu via Std-Discussion <std-discussion_at_[hidden]> wrote:
>The most surprising UB-based wrong optimization to me, ever, was that the
>following program would crash, instead of looping infinitely, when compiled
>by certain versions of Clang:
>
>int main()
>{
> for (;;) {
> }
>}
>
>Of course, I understand the reason now (and aware that it is now "fixed"),
>and I am really trying hard to justify this optimization when teaching
>people about undefined behaviour. Unfortunately, I have not found a case
>where a compiler can do loop fusion, which I suppose was a reason for the
>forward progress guarantee. (On the contrary, I have found that loop
>fission is more common, supposedly beneficial due to cache locality and
>vectorization.)
>
>I am wondering what are the real-world benefits of the forward progress
>guarantee today.... They probably existed, but are they still there? (If
>not, should we ...?)
>
>Best regards,
>
>--
>Yongwei Wu
>URL: http://wyw.dcweb.cn/

Received on 2025-09-17 08:39:09