News for hackers. Stuff that matters.
Re:“Pack it in, mathematicians, someone owes LLVM a million ... by cjfd on Thursday August 19, 2021 @09:39AM (#28233682)
Is it actually true that endless loops are undefined behavior? This statement does not make sense at face value. I am aware that sometimes UB is used to throw away code, but is an endless loop really UB? Anyway, compiling while(true); in g++ with -O4 just yields a program that runs forerver....
Re:“Pack it in, mathematicians, someone owes LLVM a million ... by detaro on Thursday August 19, 2021 @09:46AM (#28233761)
Compilers choose to not remove it in this case, probably because there is no clean way of making assumptions that provide a way out, unlike in the example from the link, but the core point is as I mentioned "making progress", specificall< the Progress guarantee (https://en.cppreference.com/w/cpp/language/memory_model#Prog...)

In a valid C++ program, every thread eventually does one of the following:

* terminate

* makes a call to an I/O library function

* performs an access through a volatile glvalue

* performs an atomic operation or a synchronization operation

It's fairly obvious how a loop that has none of these side-effects is thus a target to get turned into one that's guaranteed to terminate.

Re:“Pack it in, mathematicians, someone owes LLVM a million ... by gizmo686 on Thursday August 19, 2021 @09:46AM (#28233765)
An infinite loop without any side effects.
Re:“Pack it in, mathematicians, someone owes LLVM a million ... by shusaku on Thursday August 19, 2021 @10:05AM (#28233971)
Optimize our an infinite loop for infinite speed up!