4.1.2 Undefined behavior

This section describes behavior that is not defined by the ANSI standard.

(1)

Character set

A message is output if a source file contains a character not specified by the character set.

(2)

Lexical elements

A message is output if there is a single or double quotation mark ("/") in the last category (a delimiter or a single non-white-space character that does not lexically match another preprocessing lexical type).

(3)

Identifiers

Since all identifier characters have meaning, there are no meaningless characters.

(4)

Identifier linkage

If the same identifier appears for both internal linkage and external linkage within a single translation unit, a warning message will be output. If there is a declaration that contains no storage class specifier, external linkage is assumed. If there is no declaration that contains no storage class specifier and both static and extern storage class specifiers are used, internal linkage is assumed.

Example 1.

int xxx;
static int xxx;    // A warning is output and xxx is handled as an external 
                   // variable.

Example 2.

static int xxx;
int xxx;           // A warning is output and xxx is handled as an external 
                   // variable.

Example 3.

extern int xxx;
static int xxx;    // A warning is output and xxx is handled as a static variable.

Example 4.

static int xxx;
extern int xxx;    // No warning is output and xxx is handled as a static variable.

Example 5.

extern int xxx;
static int xxx;    // A warning is output and xxx is handled as an external 
                   // variable.
int xxx;           // A warning is output and xxx is handled as an external 
                   // variable.

(5)

Compatible type and composite type

All declarations referencing the same object or function must be compatible. If they are not compatible within a single translation unit, a message is output. Otherwise, it is undefined.

(6)

Character constants

Specific non-graphical characters can be expressed by means of extended notation, consisting of a backslash (\) followed by a lower-case letter. The following are available: \a, \b, \f, \n, \r, \t, and \v. There is no other extended notation; other letters following a backslash (\) become that letter.

(7)

String literals - concatenation

When a simple string literal is adjacent to a wide string literal token, they are concatenated into a wide string literal.

(8)

String literals - modification

Users modify string literals at their own risk.

(9)

Header names

If the following characters appear in strings between the delimiter characters < and >, or between two double quotation marks ("), then they are treated as part of the file name: characters, comma (,), double quote ("), two slashes (//), or slash-asterisk (/*). The backslash (\) is treated as a folder separator, not as an escape character.

(10)

Floating point type and integer type

If a floating-point type is typecast into an integral type, and the integer portion cannot be expressed as an integral type, then it is undefined.

(11)

Lvalues and function specifiers

If the lvalue has an incomplete type and does not have an array type, then the CC-RL operation is undefined.

(12)

Function calls - number of arguments

If the number of arguments does not match the number of formal parameters, then the CC-RL operation is undefined.

(13)

Function calls - types of extended parameters

If a function is defined without a function prototype, and the types of the extended arguments do not match the types of the extended formal parameters, then it is undefined.

(14)

Function calls - incompatible types

If a function is defined with a type that is not compatible with the type specified by the expression indicating the called function, then it is undefined.

(15)

Function calls - incompatible types

If a function is defined in a form that includes a function prototype, and the type of an extended argument is not compatible with that of a formal parameter, or if the function prototype ends with an ellipsis, then it is undefined.

(16)

Addresses and indirection operators

If an incorrect value is assigned to a pointer, then the behavior of the unary * operator will either output a message, obtain an undefined value, or result in an illegal access, depending on the hardware design and the contents of the incorrect value.

(17)

Cast operator - function pointer casts

If a typecast pointer is used to call a function with other than the original type, then it is undefined.

(18)

Cast operator - integral type casts

If a pointer is cast into an integral type, and the amount of storage is too small, then it is undefined.

(19)

Multiplicative operators

A message will be output and code for a divide by zero will be generated if a divide by zero is detected during compilation.

(20)

Additive operators - non-array pointers

If addition or subtraction is performed on a pointer that does other than indicate elements in an array object, then it is undefined.

(21)

Additive operators - subtracting a pointer from another array

If subtraction is performed using two pointers that do not indicate elements in the same array object, then it is undefined.

(22)

Bitwise shift operators

If the right operand is negative or the expanded left operand is wider than the bit width, then it is undefined.

(23)

Function operators - pointers

If the objects referred to by the pointers being compared are not members of the same aggregate or union object, then it is undefined.

(24)

Simple assignment

If a value stored in an object is accessed via another object that overlaps that object's storage area in some way, then the overlapping portion must match exactly. Furthermore, the types of the two objects must have modified or non-modified versions with compatible types. Assignment to non-matching overlapping storage could cause the value of the assignment source to become corrupted. The value after assignment is not guaranteed.

(25)

Structure and union specifiers

If the member declaration list does not include named members, then a message will be output warning. Note, however, that the same message will be output accompanied by an error if the -strict_std option is specified.

(26)

Type modifiers - const

If an object defined with a const modifier is modified using an lvalue that is the non-const modified version, then it is undefined.

(27)

Type modifiers - volatile

If an object defined with a const modifier is modified using an lvalue that is the non-const modified version, then it is undefined.

(28)

return statements

If a return statement without an expression is executed, and the caller uses the return value of the function, then it is undefined.

(29)

Function definitions

If a function taking a variable number of arguments is defined without a parameter type list that ends with an ellipsis, then the values of the formal parameters will be undefined.

(30)

Conditional inclusion

If a replacement operation generates a "defined" token, or if the usage of the "defined" unary operator before macro replacement does not match one of the two formats specified in the constraints, then it is undefined.

(31)

Macro replacement - arguments not containing preprocessing tokens

If the arguments (before argument replacement) do not contain preprocessing tokens, then it is undefined.

(32)

Macro replacement - arguments with preprocessing directives

If an argument list contains a preprocessor token stream that would function as a processing directive in another circumstance, then it is undefined.

(33)

# operator

A message is output if the results of replacement are not a correct simple string literal.

(34)

## operator

A message is output if the results of replacement are not a correct preprocessing tokens.