6.5.8 Relational operators

Previous Table of Contents

1187

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

1188 One of the following shall hold:

1189 —  both operands have real type;

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

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

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

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

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

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

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

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

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

1199 In all other cases, the behavior is undefined.

1200 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)

1201 The result has type int.

Next

Created at: 2005-06-29 02:19:00 The text from WG14/N1124 is copyright © ISO