• No results found

6.4 Lexical elements

6.4.8 Preprocessing numbers

Syntax

1 pp-number:

digit . digit

pp-number digit

pp-number identifier-nondigit pp-number opt digit

pp-number opt identifier-nondigit pp-number e sign

pp-number E sign pp-number p sign pp-number P sign pp-number .

Description

2 A preprocessing number begins with a digit optionally preceded by a period (.) and may be followed by valid identifier characters and the character sequences e+, e-, E+, E-, p+, p-, P+, or P-.

3 Preprocessing number tokens lexically include all floating and integer constant tokens.

Semantics

4 A preprocessing number does not have type or a value; it acquires both after a successful conversion (as part of translation phase 7) to a floating constant token or an integer constant token.

89)Thus, sequences of characters that resemble escape sequences cause undefined behavior.

90)For an example of a header name preprocessing token used in a#pragmadirective, see 6.10.9.

6.4.9 Comments

1 Except within a character constant, a string literal, or a comment, the characters/*introduce a comment. The contents of such a comment are examined only to identify multibyte characters and to find the characters*/that terminate it.91)

2 Except within a character constant, a string literal, or a comment, the characters//introduce a comment that includes all multibyte characters up to, but not including, the next new-line character.

The contents of such a comment are examined only to identify multibyte characters and to find the terminating new-line character.

3 EXAMPLE

"a//b" // four-character string literal

#include "//e" // undefined behavior

// */ // comment, not syntax error

f = g/**//h; // equivalent to f = g / h;

//\

i(); // part of a two-line comment

/\

/ j(); // part of a two-line comment

#define glue(x,y) x##y

glue(/,/) k(); // syntax error, not comment /*//*/ l(); // equivalent to l();

m = n//**/o

+ p; // equivalent to m = n + p;

91)Thus,/*. . .*/comments do not nest.

6.5 Expressions

1 An expression is a sequence of operators and operands that specifies computation of a value,92)or that designates an object or a function, or that generates side effects, or that performs a combination thereof. The value computations of the operands of an operator are sequenced before the value computation of the result of the operator.

2 If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined. If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.93)

3 The grouping of operators and operands is indicated by the syntax.94) Except as specified later, side effects and value computations of subexpressions are unsequenced.95)

4 Some operators (the unary operator~, and the binary operators<<,>>,&,^, and|, collectively described as bitwise operators) are required to have operands that have integer type. These operators yield values that depend on the internal representations of integers, and have implementation-defined and unimplementation-defined aspects for signed types.

5 If an exceptional condition occurs during the evaluation of an expression (that is, if the result is not mathematically defined or not in the range of representable values for its type), the behavior is undefined.

6 The effective type of an object for an access to its stored value is the declared type of the object, if any.96) If a value is stored into an object having no declared type through an lvalue having a type that is not a character type, then the type of the lvalue becomes the effective type of the object for that access and for subsequent accesses that do not modify the stored value. If a value is copied into an object having no declared type usingmemcpyormemmove, or is copied as an array of character type, then the effective type of the modified object for that access and for subsequent accesses that do not modify the value is the effective type of the object from which the value is copied, if it has one. For all other accesses to an object having no declared type, the effective type of the object is simply the type of the lvalue used for the access.

7 An object shall have its stored value accessed only by an lvalue expression that has one of the following types:97)

— a type compatible with the effective type of the object,

— a qualified version of a type compatible with the effective type of the object,

92)Annex H documents the extent to which the C language supports the ISO/IEC 10967–1 standard for language-independent arithmetic (LIA–1).

93)This paragraph renders undefined statement expressions such as i = ++i + 1;

a[i++] = i;

while allowing i = i + 1;

a[i] = i;

94)The syntax specifies the precedence of operators in the evaluation of an expression, which is the same as the order of the major subclauses of this subclause, highest precedence first. Thus, for example, the expressions allowed as the operands of the binary+ operator (6.5.6) are those expressions defined in 6.5.1 through 6.5.6. The exceptions are cast expressions (6.5.4) as operands of unary operators (6.5.3), and an operand contained between any of the following pairs of operators:

grouping parentheses()(6.5.1), subscripting brackets[](6.5.2.1), function-call parentheses()(6.5.2.2), and the conditional operator?:(6.5.15).

Within each major subclause, the operators have the same precedence. Left- or right-associativity is indicated in each subclause by the syntax for the expressions discussed therein.

95)In an expression that is evaluated more than once during the execution of a program, unsequenced and indeterminately sequenced evaluations of its subexpressions need not be performed consistently in different evaluations.

96)Allocated objects have no declared type.

97)The intent of this list is to specify those circumstances in which an object can or cannot be aliased.

— a type that is the signed or unsigned type corresponding to the effective type of the object,

— a type that is the signed or unsigned type corresponding to a qualified version of the effective type of the object,

— an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), or

— a character type.

8 A floating expression may be contracted, that is, evaluated as though it were a single opera-tion, thereby omitting rounding errors implied by the source code and the expression evalua-tion method.98) TheFP_CONTRACTpragma in<math.h>provides a way to disallow contracted expressions. Otherwise, whether and how expressions are contracted is implementation-defined.99)

9 Operators involving decimal floating types are evaluated according to the semantics of IEC 60559, including production of results with the preferred quantum exponent as specified in IEC 60559.

Forward references: theFP_CONTRACTpragma (7.12.2), copying functions (7.24.2).