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

Here's the relevant part of the C++ standard:

> 6.9.2.2 Forward progress [intro.progress]

> The implementation may assume that any thread will eventually do one of the following:

> — terminate,

> — make a call to a library I/O function,

> — perform an access through a volatile glvalue, or

> — perform a synchronization operation or an atomic operation.

That loop doesn't ever do any of the second through fourth things, and if it didn't return true, then it would never terminate either, so Clang is allowed to assume that it will eventually return true. And since the loop doesn't have any other effects visible outside the function, it can be optimized away entirely.



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

Search: