p.77 K&R C says the output of the following program is undefined, but current version of Xcode gives no warning. Is it still undefined in current standard? What about in
A compiler won't warn you about all undefined programs. In the following line:
printf("%d" , my_m() - my_m());
the order of the calls my_m()
is unspecified. The compiler might decide to call either the first one or the second one first. Since the function returns 42
on the first call and 57
on the second call the result is either 42 - 57
or 57 - 42
.
Edit: I missed the difference between undefined and unspecified, see Jerry Coffins answer for details about that.