C programs are understood in terms of the CAM (C Abstract Machine).
The compiler's job is to build a program that produces the same output as the CAM would for a given program.
The CAM says that a variable can only be read, or read-to-modify, once between two sequence points.
There are no sequence points between the i++ and i+1, so this produces a read/write conflict, which means that the program has undefined behavior in the CAM, and so the compiler can do whatever it wants.
It could crash, or print out 23, 37 or -9, 12, and these would all be equally correct behaviors.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
C programs are understood in terms of the CAM (C Abstract Machine).
The compiler's job is to build a program that produces the same output as the CAM would for a given program.
The CAM says that a variable can only be read, or read-to-modify, once between two sequence points.
There are no sequence points between the i++ and i+1, so this produces a read/write conflict, which means that the program has undefined behavior in the CAM, and so the compiler can do whatever it wants.
It could crash, or print out 23, 37 or -9, 12, and these would all be equally correct behaviors.