Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added an example of undefined behavior.

...

Nonportable Behavior

Definition

Annex J Section

unspecified behavior

Behavior for which the standard provides two or more possibilities and imposes no further requirements on which is chosen in any instance.

J.1

undefined behavior

Behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which the standard imposes no requirements. An example of undefined behavior is the behavior on integer overflow.

J.2

implementation-defined behavior

Unspecified behavior whereby each implementation documents how the choice is made.

J.3

locale-specific behavior

Behavior that depends on local conventions of nationality, culture, and language that each implementation documents.

J.4

An example of implementation-defined undefined behavior is the propagation of the high-order bit when a signed integer is shifted rightpassing a NULL char* pointer as an argument to the printf function corresponding to the %s format specification. While some implementations (such as the GNU C Library) provide well-defined semantics for this case, others do not and cause programs that rely on this behavior to fail abnormally.

An example of unspecified behavior is the order in which the arguments to a function are evaluated.

An example of implementation-defined behavior is the propagation of the high-order bit when a signed integer is shifted right.

Most legitimate platform dependencies can and should be isolated in separate modules that use portable interfaces but platform-specific implementations.

...