Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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

The same thing happens when I let clang++ compile a C version as C++:

https://godbolt.org/z/MxcGfWhej

However, if I compile it as C with clang, I get an infinite loop:

https://godbolt.org/z/x63fo33Wa



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: