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

My point is that if a loop

- doesn't terminate, doesn't have side effects -> optimization doesn't matter

- doesn't terminate, has side effects -> optimization isn't valid

- does terminate, doesn't has side effects -> optimization would be valid, but why would such a loop exist? One example that was brought up was generic code, but I'm not entirely convinced yet.



Because of interaction with other undefined behaviour (in the body of your loop), you might think you are in a different case than what the compiler thinks.

Also the definition of 'side effect' here is a weird one: reading and writing to variables is not considered a side effect, even though a different thread could change them while your loop is running.




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

Search: