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-whitespace 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 binding

A message is output if both internal and external binding was performed on the same identifier within a translation unit.

(5)

Compatible type and composite type

All declarations referencing the same object or function must be compatible. Otherwise, a message will be output.

(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.

(10)

Floating point type and integral 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 an incomplete type becomes an value, then it is undefined..

(12)

Function calls - number of arguments

If there are not enough actual parameters, then it 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 the values of the formal parameters will be 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 the return value of the function will be invalid.

(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 will be interpreted as the type of the formal parameter.

(16)

Addresses and indirection operators

If an incorrect value is assigned to a pointer, then the behavior of the unary * operator will either 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 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.

(25)

Structure and union specifiers

If the member declaration list does not include named members, then a message will be output warning that the list has no effect. Note, however, that the same message will be output accompanied by an error if the -Xansi 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

A message will be output if a return statement without an expression is executed, and the caller uses the return value of the function, and there is a declaration. If there is no declaration, then the return value of the function will be 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 will be handled as an ordinary "defined".

(31)

Macro replacement - arguments not containing preprocessing tokens

A message is output if the arguments (before argument replacement) do not contain preprocessing tokens.

(32)

Macro replacement - arguments with preprocessing directives

A message is output if an argument list contains a preprocessor token stream that would function as a processing directive in another circumstance.

(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 simple string literal.