2 ms·
How they treat infinite loops that obviously never terminate (e.g. while (1)) is probably of greater interest. The first link gives this code: namespace { voi
by ryao 3y ago
How they treat infinite loops that obviously never terminate (e.g. while (1)) is probably of greater interest. The first link gives this code:
namespace {
void Panic() {
while (1);
}
} // namespace
extern "C" void kernel() {
Panic();
}
The clang++ really does optimize this away:
https://godbolt.org/z/1Wf135918 https://godbolt.org/z/1Wf135918
The same thing happens when I let clang++ compile a C version as C++:
https://godbolt.org/z/MxcGfWhej https://godbolt.org/z/MxcGfWhej
However, if I compile it as C with clang, I get an infinite loop:
https://godbolt.org/z/x63fo33Wa https://godbolt.org/z/x63fo33Wa