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

In the answer to 9 I don't see why 'Evaluating ++i + ++i would produce undefined behavior'


There's no http://en.wikipedia.org/wiki/Sequence_point between the two increments, so the standard allows the compiler to do pretty much anything, even http://catb.org/jargon/html/N/nasal-demons.html. The way I've heard it, these operators were added to take advantage of pre- and post-increment hardware support in the PDP-11 (forty years ago!), and everyone just knew what would happen, but ANSI later wanted compilers to have enough latitude to take advantage of other hardware which behaves differently.


Just when I thought (after completing the puzzles) that C is reasonably reasonable language, I learn that the execution order of 'f()+g()' is unspecified. Wow!




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

Search: