Interview Questions

What does the warning semantics of change in ANSI C mean?

C Interview Questions and Answers


(Continued from previous question...)

What does the warning semantics of change in ANSI C mean?

Q: What does the warning ``semantics of `>' change in ANSI C'' mean?

This message represents an attempt by certain (perhaps overzealous) compilers to warn you that some code may perform differently under the ANSI C ``value preserving'' rules than under the older ``unsigned preserving'' rules.

The wording of this message is rather confusing because what has changed is not really the semantics of the < operator itself (in fact, almost any C operator can appear in the message), but rather the semantics of the implicit conversions which always occur when two dissimilar types meet across a binary operator, or when a narrow integral type must be promoted.

(If you didn't think you were using any unsigned values in your expression, the most likely culprit is strlen. In Standard C, strlen returns size_t, which is an unsigned type.)

(Continued on next question...)

Other Interview Questions