6.5.8 Relational operators

Previous Table of Contents "New C Standard" commentary

1197

relational-expression:
                shift-expression
                relational-expression <  shift-expression
                relational-expression >  shift-expression
                relational-expression <= shift-expression
                relational-expression >= shift-expression

1198 One of the following shall hold:

1199 —  both operands have real type;

1200 —  both operands are pointers to qualified or unqualified versions of compatible object types; or

1201 —  both operands are pointers to qualified or unqualified versions of compatible incomplete types.

1202 If both of the operands have arithmetic type, the usual arithmetic conversions are performed.

1203 For the purposes of these operators, a pointer to an object that is not an element of an array behaves the same as a pointer to the first element of an array of length one with the type of the object as its element type.

1204 When two pointers are compared, the result depends on the relative locations in the address space of the objects pointed to.

1205 If two pointers to object or incomplete types both point to the same object, or both point one past the last element of the same array object, they compare equal.

1206 If the objects pointed to are members of the same aggregate object, pointers to structure members declared later compare greater than pointers to members declared earlier in the structure, and pointers to array elements with larger subscript values compare greater than pointers to elements of the same array with lower subscript values.

1207 All pointers to members of the same union object compare equal.

1208 If the expression P points to an element of an array object and the expression Q points to the last element of the same array object, the pointer expression Q+1 compares greater than P.

1209 In all other cases, the behavior is undefined.

1210 Each of the operators < (less than), > (greater than), <= (less than or equal to), and >= (greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is false.90)

1211 The result has type int.

Next

Created at: 2008-01-30 02:39:43 The text from WG14/N1256 is copyright © ISO