re: Is "C Programming language" Still Worth Learning in 2021? VIEW POST

re: It's worth learning in order to fully appreciate the wonders of undefined behavior. Consider the following C program -- what does it do? #includ...

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


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

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."

Thanks for clarifying! That makes more sense.

Code of Conduct Report abuse