News for hackers. Stuff that matters.
Re:A glimpse of undefined behavior in C by jfoutz on Saturday November 30, 2013 @04:12PM (#6824640)
it's a little weirder though. int main(int argc, char argv) { int a = 0; printf("%i %i %i\n", a, a++, a++); }

will give "0 0 1" (gcc 4.2.1), the increment "shouldn't" happen until after the ; if you're going with post statement. I think your rule would expect "0 0 0" with a being 2 after the printf.

BUT! you get a warning, so that's nice.

Re:A glimpse of undefined behavior in C by jacquesgt on Saturday November 30, 2013 @05:45PM (#6825018)
The issue here is that the order of function argument evaluation is undefined. If the commas weren't inside of a function call, they would result in sequence points. So, this would be well defined:

   int a = 0, b, c;
   b = a++, c = a++;
But, there is no defined order in which to evaluate function arguments.
Re:A glimpse of undefined behavior in C by NAFV_P on Saturday November 30, 2013 @06:40PM (#6825215)
The example given in the article shows all the code, but your example involves a function so the code in question is hidden. The behaviour partially depends on how the function is written.

"0 0 1" is what I would expect from your code, and identifier a should end up as 2.