3 ms·
> The C++ standard allows compilers to assume that loops terminate. Technically, it doesn't, but it requires programs to make forward progress, which is define
by Denvercoder9 5y ago
> The C++ standard allows compilers to assume that loops terminate.
Technically, it doesn't, but it requires programs to make forward progress, which is defined as either terminating, calling I/O functions, accessing a volatile variable or performing an atomic or synchronization operation. Infinite loops that'll eventually do one of these are perfectly valid C++ and don't have to terminate.
- HelloNurse 5y agoIt optimizes "waste an unpredictable time doing arithmetic without side effects, then return 1" to "return 1 without looking at the input". The relation between that machine arithmetic and the Collatz conjecture is irrelevant.
- Denvercoder9 5y agoI don't think you're responding to the right comment?