From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anjul Srivastava To: "'Linus Torvalds'" , Marc Espie Cc: gcc@gcc.gnu.org Subject: RE: GCC's statement expression extension Date: Fri, 28 Jul 2000 12:01:00 -0000 Message-id: <383558CE36E2D311AC790004AC33FF67616CD7@OZ> X-SW-Source: 2000-07/msg00943.html It does not have undefined behavior, and will always evaluate to: three plus twice the old value of i. But that's besides the point. Even if you consider: ++i + i++ the behavior is undefined, but it cannot format your hard disk and still remain conforming. It cannot ever return 42, regardless of the value of i. (It can only return an odd integer but this again is besides the point). The C/C++ standards leave only the order of evaluation undefined. They say that of the possible choices of order of evaluation, which one is selected is undefined. But the fact that one of them is selected is mandated by the standard. That's why 42 is out, and formatting the hard disk is out, as also returning 43 when the value of i is 5 is not possible unless you violate the standard. -----Original Message----- From: Linus Torvalds [ mailto:torvalds@transmeta.com ] Think about a basic C (and C++) expression: ++i + ++i What does the C standard say about the above? Right. It has undefined behavior. It can return 42. It can format your harddisk. And the compiler is still strictly conforming, and yes, you get the occasional "bug-report" about it, but everybody agrees that it _is_ undefined behaviour, and everybody even agrees on _why_ it is undefined behaviour, and there is really no problem.