(ref.doc)clamage 190495
Next johnson 150695
Prev: clamage 180495
Up: Usenet
From: [email protected] (Steve Clamage)
Newsgroups: comp.lang.c++
Date: 19 Apr 1995 15:11:18 GMT
The C and C++ standards define four categories of system behavior with
regard to a source-code program.
1. Required behavior. The system must respond in a defined way.
Example: If x and y have type int and their sum is in the range
-INT_MAX...+INT_MAX, the result of evaluating x+y must be equal to the
sum using ordinary arithmetic.
2. Implementation-defined behavior. The system is allowed to implement
any of a number of behaviors, but must document what the behavior is.
Example: The result of x%y where x and y have integral type and y is
negative may be either positive or negative, but the system must
document which it will be.
3. Unspecified behavior. The system is allowed to implement any of a
number of behaviors, but doesn't have to tell you which it implements,
or even be consistent within the same program or function. Example:
The arguments to a function must all be evaluated before the function
is called, but they may be evaluated in any order. The system need not
be consistent in choosing an order, and need not tell you how to
predict the order chosen.
4. Undefined behavior. The standard places no requirements whatever on
the system. Literally any behavior is permitted (by the standard, if
not by customers). Example: If you dereference a null pointer, you
might get the value zero, or an arbitrary value, or a program abort,
or a signal of some kind, or some sort of exception, or the
implementation might send email to your boss about your careless
programming habits. Or all of the above. Or something else entirely.
automatically generated by info2www version 1.2.2.8