Date: Wed, 17 Sep 2025 10:11:35 +0800
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,
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 02:11:50