WG14 Document: N1060
Date: 2004-03-31
use of an unspecified value, or otherbefore
behavior where
expressionsto:
expression
- -
- A byte with all bits zero shall be interpreted as a null character independent of shift state. Such a byte shall not occur as part of any other multibyte character.
An implementation may give zero and non-numeric values (such as infinities and NaNs) a sign or may leave them unsigned. Wherever such values are unsigned, any requirement in this International Standard to retrieve the sign shall produce an unspecified sign, and any requirement to set the sign shall be ignored.
The accuracy of the floating-point operations ( +, -, *, /) and of the library functions in <math.h> and <complex.h> that return floating-point results is implementation defined, as is the accuracy of the conversion between floating-point internal representations and string representations performed by the library routines in <stdio.h>, <stdlib.h> and <wchar.h>. The implementation may state that the accuracy is unknown.
When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified value.^{42)} The value of a struct or union object is never a trap representation, even though the value of a member of a struct or union object may be a trap representation.
42) Thus, for example, structure assignment need not copy any padding bits.
When a value is stored in a member of an object of union type, the bytes of the object representation that do not correspond to that member but do correspond to other members take unspecified values.
For any integer type, the object representation where all the bits are zero shall be a representation of the value zero in that type.
An object or expression with an integer type whose integer conversion rank is less than or equal to the rank of int and unsigned int.
The keyword _Imaginary is reserved for specifying imaginary types.^{footnote}
^{footnote}One possible specification for imaginary types is Annex G.
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.
The asymmetric appearance of these constraints with respect to type qualifiers is due to the conversion (specified in 6.3.2.1) that changes lvalues to "the value of the expression" which removes any type qualifiers that were applied to the type category of the expression (for example, it removes const but not volatile from the type int volatile * const).
- float _Imaginary
- double _Imaginary
- long double _Imaginary
The type specifier _Complex shall not be used if the implementation does not provide complex types.^{101}
^{101}Freestanding implementations are not required to provide complex types.
The expression that specifies the width of a bit-field shall be an integer constant expression that has nonnegative value that shall not exceed the width of an object of the type that is specified if the colon and expression are omitted.
In most situations, the flexible array member is ignored. In particular, the size of the structure is as if the flexible array member were omitted except that it may have more trailing padding than the omission would imply. However, when a . (or ->) operator has a left operand that is (a pointer to) a structure with a flexible array member and the right operand names that member, it behaves as if that member were replaced with the longest array (with the same element type) that would not make the structure larger than the object being accessed; the offset of the array shall remain that of the flexible array member, even if this would differ from that of the replacement array.
EXAMPLE After the declaration:
struct s { int n; double d[]; };the structure struct s has a flexible array member d. A typical way to use this is:int m = /* some value */; struct s *p = malloc (sizeof (struct s) + sizeof (double [m]));and assuming that the call to malloc succeeds, the object pointed to by p behaves, for most purposes, as if p had been declared as:struct { int n; double d[m]; } *s1;(there are circumstances in which this equivalence is broken; in particular, the offsets of member d might not be the same).
Following the above declaration:
struct s t1 = { 0 }; // valid struct s t2 = { 1, { 4.2 }}; // invalid t1.n = 4; // valid t1.d[0] = 4.2; // might be undefined behaviorThe initialization of t2 is invalid (and violates a constraint) because struct s is treated as if it does not contain member d. The assignment to t1.d[0] is probably undefined behavior, but it is possible thatsizeof (struct s) >= offsetof (struct s, d) + sizeof (double)in which case the assignment would be legitimate. Nevertheless it cannot appear in strictly conforming code.
After the further declaration:
struct ss { int n; };the expressions:sizeof (struct s) >= sizeof (struct ss) sizeof (struct s) >= offsetof (struct s, d)are always equal to 1.
If sizeof (double) is 8, then after the following code is executed:struct s *s1; struct s *s2; s1 = malloc(sizeof (struct s) + 64); s2 = malloc(sizeof (struct s) + 46);and assuming that the calls to malloc succeed, the objects pointed to by s1 and s2 behave, for most purposes, as if the identifiers had been declared as:struct { int n; double d[8]; } *s1; struct { int n; double d[5]; } *s2;
Following the further successful assignments:s1 = malloc(sizeof (struct s) + 10); s2 = malloc(sizeof (struct s) + 6);they then behave as if the declarations were:struct { int n; double d[1]; } *s1, *s2;and:double *dp; dp = &(s1->d[0]); // valid *dp = 42; // valid dp = &(s2->d[0]); // valid *dp = 42; // undefined behavior
The assignment:*s1 = *s2;only copies the member n; if any of the array elements are within the first sizeof (struct s) bytes of the structure, these might be copied or simply overwritten with indeterminate values.
If, in a parameter declaration, an identifier can be treated as a typedef name or as a parameter name, it shall be taken as a typedef name.
and then each preprocessing token is converted into a token. The resulting tokens compose the controlling constant expression which is evaluated according to the rules of 6.6. For the purposes of this token conversion and evaluation all signed integer types and all unsigned integer types act as if they have the same representation as, respectively, the types intmax_t and uintmax_t defined in the header <stdint.h>.
Thus on an implementation where INT_MAX is 0x7FFF and UINT_MAX is 0xFFFF, the constant 0x8000 is signed and positive within a #if expression even though it is unsigned in translation phase 7.
Despite the name, a non-directive is a preprocessing directive.
- __STDC_ISO_10646__
- An integer constant of the form yyyymmL (for example, 199712L). If this symbol is defined, then every character in the "Unicode required set", when stored in an object of type wchar_t, has the same value as the short identifier of that character. The "Unicode required set" consists of all the characters that are defined by ISO/IEC 10646, along with all amendments and technical corrigenda, as of the specified year and month.
The macroIexpands to _Complex_I.^{162}
Notwithstanding the provisions of subclause 7.1.3, a program may undefine and perhaps then redefine the macros complex and I.
If no such macros are defined, FE_ALL_EXCEPT shall be defined as 0.
The number classification macros are:FP_INFINITE
FP_NAN
FP_NORMAL
FP_SUBNORMAL
FP_ZERO
If defined, these macros expand to the integer constant 1.
A range error may occur if x is 0.to
A domain error or range error may occur if x is 0, infinite, or NaN.
If the correct value is outside the range of the return type, the numeric result is unspecified.
A domain error may occur if the argument is zero.to
A domain error or range error may occur if the argument is zero.
A domain error may occur if x is zero and y is less than or equal to zero.to:
A domain error may occur if x is zero and y is zero. A domain error or range error may occur if x is zero and y is less than zero.
A domain error occurs if x is a negative integer or if the result cannot be represented when x is zero.to
A domain error or range error may occur if x is a negative integer or zero.
If the rounded value is outside the range of the return type, the numeric result is unspecified. A range error may occur if the magnitude of x is too large.to:
If the rounded value is outside the range of the return type, the numeric result is unspecified, and a domain error or range error may occur.
If the rounded value is outside the range of the return type, the numeric result is unspecified. A range error may occur if the magnitude of x is too large.to:
If the rounded value is outside the range of the return type, the numeric result is unspecified, and a domain error or range error may occur.
If y is zero, whether a domain error occurs or the remainder functions return zero is implementation defined.
If y is zero, whether a domain error occurs or the remainder functions return zero is implementation defined.
If y is zero, the quotient stored is unspecified.
A range error may occur.
wchar_t
which is an integer type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales; the null character shall have the code value zero.
These types are optional. However, if an implementation provides integer types with widths of 8, 16, 32, or 64 bits, no padding bits, and (for the signed types) that have a two's complement representation, it shall define the corresponding typedef names.
An implementation shall define only the macros corresponding to those typedef names it actually provides.
A freestanding implementation need not provide all of these types.
Finally, unless the # flag is used, any trailing zeroes are removed from the fractional portion of the result and the decimal-point character is removed if there is no fractional portion remaining.
- g,G
- A double argument representing a floating-point number is converted in style f or e (or in style F or E in the case of a G conversion specifier), depending on the value converted and the precision. Let P equal the precision if non-zero, 6 if the precision is omitted, or 1 if the precision is zero. Then, if a conversion with style E would have an exponent of X:
- if P > X >= -4, the conversion is with style f (or F) and precision P - (X + 1).
- otherwise the conversion is with style e (or E) and precision P - 1.
fprintf(stdout, "|%13lc|\n", (wint_t) wstr[5]);
For all functions in this subclause, each character shall be interpreted as if it had the type unsigned char (and therefore every possible object representation is valid and has a different value).
The btowc returnsto
The btowc function returns
The wctob returnsto
The wctob function returns
int wmemcmp(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n);to:
int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);
wmemcmp to follow wcsncpy
wmemcpy and wmemmove to follow wcsxfrm
wcslen to follow wmemchr
If the correct result is outside the range of the return type, the numeric result is unspecified and the "invalid" floating-point exception is raised.
No additional requirements beyond those on nextafter.
There is a new keyword _Imaginary, which is used to specify imaginary types. It is used as a type-specifier within declaration-specifiers in the same way as _Complex is (thus "_Imaginary float" is a valid type name).
When a value of imaginary type is converted to a real type other than _Bool, the result is a positive zero. See 6.3.1.2.
The macroimaginaryand_Imaginary_Iare defined, respectively, as _Imaginary and a constant expression of type const float _Imaginary with the value of the imaginary unit. The macroIis defined to be _Imaginary_I (not _Complex_I as stated in 7.3). Notwithstanding the provisions of 7.1.3, a program may undefine and then perhaps redefine the macro imaginary.
- -
- Whether a domain error occurs or zero is returned when an remainder function has a second argument of zero (7.12.10.2).
- -
- Whether a domain error occurs or zero is returned when an remquo function has a second argument of zero (7.12.10.3).