DEV Community

loading...

Discussion on: Is "C Programming language" Still Worth Learning in 2021?

Collapse
stokesm profile image
Matthew Stokes • Edited

Print 1 and then 2? Genuinely curious where is the undefined behaviour? :)

Collapse
stokesm profile image
Matthew Stokes

Ah, I see it now. There is no guarantee the increment will happen before the print. Only before the next sequence point!

Thread Thread
pentacular profile image
pentacular

The increment must happen before the print, as there is a sequence point between the evaluation of the arguments and the call.

But there are no sequence points between the evaluations of the arguments.

Leading to undefined behavior of the case that "Between two sequence points, an object is modified more than once, or is modified and the prior value is read other than to determine the value to be stored."

Thread Thread
stokesm profile image
Matthew Stokes

Thanks for clarifying! That makes more sense.