Стандарт языка Си С99 TC (1113411), страница 13
Текст из файла (страница 13)
If the value ofthe integral part cannot be represented by the integer type, the behavior is undefined.50)2When a value of integer type is converted to a real floating type, if the value beingconverted can be represented exactly in the new type, it is unchanged. If the value beingconverted is in the range of values that can be represented but cannot be represented48) The integer promotions are applied only: as part of the usual arithmetic conversions, to certainargument expressions, to the operands of the unary +, -, and ~ operators, and to both operands of theshift operators, as specified by their respective subclauses.49) The rules describe arithmetic on the mathematical value, not the value of a given type of expression.50) The remaindering operation performed when a value of integer type is converted to unsigned typeneed not be performed when a value of real floating type is converted to unsigned type.
Thus, therange of portable real floating values is (−1, Utype_MAX+1).§6.3.1.4Language43ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256exactly, the result is either the nearest higher or nearest lower representable value, chosenin an implementation-defined manner. If the value being converted is outside the range ofvalues that can be represented, the behavior is undefined.6.3.1.5 Real floating types1When a float is promoted to double or long double, or a double is promotedto long double, its value is unchanged (if the source value is represented in theprecision and range of its type).2When a double is demoted to float, a long double is demoted to double orfloat, or a value being represented in greater precision and range than required by itssemantic type (see 6.3.1.8) is explicitly converted (including to its own type), if the valuebeing converted can be represented exactly in the new type, it is unchanged.
If the valuebeing converted is in the range of values that can be represented but cannot berepresented exactly, the result is either the nearest higher or nearest lower representablevalue, chosen in an implementation-defined manner. If the value being converted isoutside the range of values that can be represented, the behavior is undefined.6.3.1.6 Complex types1When a value of complex type is converted to another complex type, both the real andimaginary parts follow the conversion rules for the corresponding real types.6.3.1.7 Real and complex1When a value of real type is converted to a complex type, the real part of the complexresult value is determined by the rules of conversion to the corresponding real type andthe imaginary part of the complex result value is a positive zero or an unsigned zero.2When a value of complex type is converted to a real type, the imaginary part of thecomplex value is discarded and the value of the real part is converted according to theconversion rules for the corresponding real type.6.3.1.8 Usual arithmetic conversions1Many operators that expect operands of arithmetic type cause conversions and yield resulttypes in a similar way.
The purpose is to determine a common real type for the operandsand result. For the specified operands, each operand is converted, without change of typedomain, to a type whose corresponding real type is the common real type. Unlessexplicitly stated otherwise, the common real type is also the corresponding real type ofthe result, whose type domain is the type domain of the operands if they are the same,and complex otherwise. This pattern is called the usual arithmetic conversions:First, if the corresponding real type of either operand is long double, the otheroperand is converted, without change of type domain, to a type whosecorresponding real type is long double.44Language§6.3.1.8WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3Otherwise, if the corresponding real type of either operand is double, the otheroperand is converted, without change of type domain, to a type whosecorresponding real type is double.Otherwise, if the corresponding real type of either operand is float, the otheroperand is converted, without change of type domain, to a type whosecorresponding real type is float.51)Otherwise, the integer promotions are performed on both operands.
Then thefollowing rules are applied to the promoted operands:If both operands have the same type, then no further conversion is needed.Otherwise, if both operands have signed integer types or both have unsignedinteger types, the operand with the type of lesser integer conversion rank isconverted to the type of the operand with greater rank.Otherwise, if the operand that has unsigned integer type has rank greater orequal to the rank of the type of the other operand, then the operand withsigned integer type is converted to the type of the operand with unsignedinteger type.Otherwise, if the type of the operand with signed integer type can representall of the values of the type of the operand with unsigned integer type, thenthe operand with unsigned integer type is converted to the type of theoperand with signed integer type.Otherwise, both operands are converted to the unsigned integer typecorresponding to the type of the operand with signed integer type.2The values of floating operands and of the results of floating expressions may berepresented in greater precision and range than that required by the type; the types are notchanged thereby.52)51) For example, addition of a double _Complex and a float entails just the conversion of thefloat operand to double (and yields a double _Complex result).52) The cast and assignment operators are still required to perform their specified conversions asdescribed in 6.3.1.4 and 6.3.1.5.§6.3.1.8Language45ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12566.3.2 Other operands6.3.2.1 Lvalues, arrays, and function designators1An lvalue is an expression with an object type or an incomplete type other than void;53)if an lvalue does not designate an object when it is evaluated, the behavior is undefined.When an object is said to have a particular type, the type is specified by the lvalue used todesignate the object.
A modifiable lvalue is an lvalue that does not have array type, doesnot have an incomplete type, does not have a const-qualified type, and if it is a structureor union, does not have any member (including, recursively, any member or element ofall contained aggregates or unions) with a const-qualified type.2Except when it is the operand of the sizeof operator, the unary & operator, the ++operator, the -- operator, or the left operand of the . operator or an assignment operator,an lvalue that does not have array type is converted to the value stored in the designatedobject (and is no longer an lvalue).
If the lvalue has qualified type, the value has theunqualified version of the type of the lvalue; otherwise, the value has the type of thelvalue. If the lvalue has an incomplete type and does not have array type, the behavior isundefined.3Except when it is the operand of the sizeof operator or the unary & operator, or is astring literal used to initialize an array, an expression that has type ‘‘array of type’’ isconverted to an expression with type ‘‘pointer to type’’ that points to the initial element ofthe array object and is not an lvalue. If the array object has register storage class, thebehavior is undefined.4A function designator is an expression that has function type. Except when it is theoperand of the sizeof operator54) or the unary & operator, a function designator withtype ‘‘function returning type’’ is converted to an expression that has type ‘‘pointer tofunction returning type’’.Forward references: address and indirection operators (6.5.3.2), assignment operators(6.5.16), common definitions <stddef.h> (7.17), initialization (6.7.8), postfixincrement and decrement operators (6.5.2.4), prefix increment and decrement operators(6.5.3.1), the sizeof operator (6.5.3.4), structure and union members (6.5.2.3).53) The name ‘‘lvalue’’ comes originally from the assignment expression E1 = E2, in which the leftoperand E1 is required to be a (modifiable) lvalue.
It is perhaps better considered as representing anobject ‘‘locator value’’. What is sometimes called ‘‘rvalue’’ is in this International Standard describedas the ‘‘value of an expression’’.An obvious example of an lvalue is an identifier of an object. As a further example, if E is a unaryexpression that is a pointer to an object, *E is an lvalue that designates the object to which E points.54) Because this conversion does not occur, the operand of the sizeof operator remains a functiondesignator and violates the constraint in 6.5.3.4.46Language§6.3.2.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC36.3.2.2 void1The (nonexistent) value of a void expression (an expression that has type void) shall notbe used in any way, and implicit or explicit conversions (except to void) shall not beapplied to such an expression.
If an expression of any other type is evaluated as a voidexpression, its value or designator is discarded. (A void expression is evaluated for itsside effects.)6.3.2.3 Pointers1A pointer to void may be converted to or from a pointer to any incomplete or objecttype. A pointer to any incomplete or object type may be converted to a pointer to voidand back again; the result shall compare equal to the original pointer.2For any qualifier q, a pointer to a non-q-qualified type may be converted to a pointer tothe q-qualified version of the type; the values stored in the original and converted pointersshall compare equal.3An integer constant expression with the value 0, or such an expression cast to typevoid *, is called a null pointer constant.55) If a null pointer constant is converted to apointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequalto a pointer to any object or function.4Conversion of a null pointer to another pointer type yields a null pointer of that type.Any two null pointers shall compare equal.5An integer may be converted to any pointer type.