That is an amazing thread. The fact that C++ apparently allows
optimizing
#include <stdio.h>
int stop = 1;
void maybeStop() {
if(stop)
for(;;);
}
int main() {
printf("hello, ");
maybeStop();
printf("world\n");
}
into
int main() {
printf("hello, world\n");
}
(as Clang does today) does not inspire confidence about disallowing moving the loop in the other example. If the compiler is allowed to assume that this loop terminates, why not the lock loop?
Maybe there is a reason, but none of this inspires confidence.
Maybe there is a reason, but none of this inspires confidence.