Стандарт языка Си С99 TC (1113411), страница 11
Текст из файла (страница 11)
Irrespective of the choice made, char is a separate type from theother two and is not compatible with either.36) Since object types do not include incomplete types, an array of incomplete type cannot be constructed.§6.2.5Language35ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256— A pointer type may be derived from a function type, an object type, or an incompletetype, called the referenced type. A pointer type describes an object whose valueprovides a reference to an entity of the referenced type. A pointer type derived fromthe referenced type T is sometimes called ‘‘pointer to T ’’.
The construction of apointer type from a referenced type is called ‘‘pointer type derivation’’.These methods of constructing derived types can be applied recursively.21Arithmetic types and pointer types are collectively called scalar types. Array andstructure types are collectively called aggregate types.37)22An array type of unknown size is an incomplete type.
It is completed, for an identifier ofthat type, by specifying the size in a later declaration (with internal or external linkage).A structure or union type of unknown content (as described in 6.7.2.3) is an incompletetype. It is completed, for all declarations of that type, by declaring the same structure orunion tag with its defining content later in the same scope.23A type has known constant size if the type is not incomplete and is not a variable lengtharray type.24Array, function, and pointer types are collectively called derived declarator types.
Adeclarator type derivation from a type T is the construction of a derived declarator typefrom T by the application of an array-type, a function-type, or a pointer-type derivation toT.25A type is characterized by its type category, which is either the outermost derivation of aderived type (as noted above in the construction of derived types), or the type itself if thetype consists of no derived types.26Any type so far mentioned is an unqualified type. Each unqualified type has severalqualified versions of its type,38) corresponding to the combinations of one, two, or allthree of the const, volatile, and restrict qualifiers.
The qualified or unqualifiedversions of a type are distinct types that belong to the same type category and have thesame representation and alignment requirements.39) A derived type is not qualified by thequalifiers (if any) of the type from which it is derived.27A pointer to void shall have the same representation and alignment requirements as apointer to a character type.39) Similarly, pointers to qualified or unqualified versions ofcompatible types shall have the same representation and alignment requirements. All37) Note that aggregate type does not include union type because an object with union type can onlycontain one member at a time.38) See 6.7.3 regarding qualified array and function types.39) The same representation and alignment requirements are meant to imply interchangeability asarguments to functions, return values from functions, and members of unions.36Language§6.2.5WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3pointers to structure types shall have the same representation and alignment requirementsas each other.
All pointers to union types shall have the same representation andalignment requirements as each other. Pointers to other types need not have the samerepresentation or alignment requirements.28EXAMPLE 1 The type designated as ‘‘float *’’ has type ‘‘pointer to float’’. Its type category ispointer, not a floating type. The const-qualified version of this type is designated as ‘‘float * const’’whereas the type designated as ‘‘const float *’’ is not a qualified type — its type is ‘‘pointer to constqualified float’’ and is a pointer to a qualified type.29EXAMPLE 2 The type designated as ‘‘struct tag (*[5])(float)’’ has type ‘‘array of pointer tofunction returning struct tag’’.
The array has length five and the function has a single parameter of typefloat. Its type category is array.Forward references: compatible type and composite type (6.2.7), declarations (6.7).6.2.6 Representations of types6.2.6.1 General1The representations of all types are unspecified except as stated in this subclause.2Except for bit-fields, objects are composed of contiguous sequences of one or more bytes,the number, order, and encoding of which are either explicitly specified orimplementation-defined.3Values stored in unsigned bit-fields and objects of type unsigned char shall berepresented using a pure binary notation.40)4Values stored in non-bit-field objects of any other object type consist of n × CHAR_BITbits, where n is the size of an object of that type, in bytes.
The value may be copied intoan object of type unsigned char [n] (e.g., by memcpy); the resulting set of bytes iscalled the object representation of the value. Values stored in bit-fields consist of m bits,where m is the size specified for the bit-field. The object representation is the set of mbits the bit-field comprises in the addressable storage unit holding it. Two values (otherthan NaNs) with the same object representation compare equal, but values that compareequal may have different object representations.5Certain object representations need not represent a value of the object type. If the storedvalue of an object has such a representation and is read by an lvalue expression that doesnot have character type, the behavior is undefined. If such a representation is producedby a side effect that modifies all or any part of the object by an lvalue expression thatdoes not have character type, the behavior is undefined.41) Such a representation is called40) A positional representation for integers that uses the binary digits 0 and 1, in which the valuesrepresented by successive bits are additive, begin with 1, and are multiplied by successive integralpowers of 2, except perhaps the bit with the highest position.
(Adapted from the American NationalDictionary for Information Processing Systems.) A byte contains CHAR_BIT bits, and the values ofCHAR_BITtype unsigned char range from 0 to 2− 1.§6.2.6.1Language37ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256a trap representation.6When a value is stored in an object of structure or union type, including in a memberobject, the bytes of the object representation that correspond to any padding bytes takeunspecified values.42) The value of a structure or union object is never a traprepresentation, even though the value of a member of the structure or union object may bea trap representation.7When a value is stored in a member of an object of union type, the bytes of the objectrepresentation that do not correspond to that member but do correspond to other memberstake unspecified values.8Where an operator is applied to a value that has more than one object representation,which object representation is used shall not affect the value of the result.43) Where avalue is stored in an object using a type that has more than one object representation forthat value, it is unspecified which representation is used, but a trap representation shallnot be generated.Forward references: declarations (6.7), expressions (6.5), lvalues, arrays, and functiondesignators (6.3.2.1).6.2.6.2 Integer types1For unsigned integer types other than unsigned char, the bits of the objectrepresentation shall be divided into two groups: value bits and padding bits (there neednot be any of the latter).
If there are N value bits, each bit shall represent a differentpower of 2 between 1 and 2 N −1 , so that objects of that type shall be capable ofrepresenting values from 0 to 2 N − 1 using a pure binary representation; this shall beknown as the value representation. The values of any padding bits are unspecified.44)2For signed integer types, the bits of the object representation shall be divided into threegroups: value bits, padding bits, and the sign bit.
There need not be any padding bits;41) Thus, an automatic variable can be initialized to a trap representation without causing undefinedbehavior, but the value of the variable cannot be used until a proper value is stored in it.42) Thus, for example, structure assignment need not copy any padding bits.43) It is possible for objects x and y with the same effective type T to have the same value when they areaccessed as objects of type T, but to have different values in other contexts.