News for hackers. Stuff that matters.
Re:A glimpse of undefined behavior in C by ezy on Saturday November 30, 2013 @06:39PM (#6825209)
I always thought this "myth" was confined to C++ code (iterators) where there may in fact be code that does something analogous to what your "postincrement()" does.

Compilers are sometimes smart enough to remove the unnecessary operation in C++ (e.g. switch to ++x themselves), but I always use ++i for the same reason people simplify their usage of C in between sequence points --- it's an easy transformation, and why tempt fate?

Re:A glimpse of undefined behavior in C by nly on Saturday November 30, 2013 @07:20PM (#6825386)
The compiler can't necessarily optimise i++ away in C++, because the ++operator or the destructor of the temporary iterator object returned may have side effects. It's still not quite equivalent to ballards postincrement() though, because the C++ standard allows for that temporary copy operation to be optimised away